Рет қаралды 230
so the flashlight script to make it equipt when you click f is _____________
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function onInputBegan(input, gameProcessed)
if gameProcessed then
return
end
if input.KeyCode == Enum.KeyCode.F then
local Flashlight = ReplicatedStorage:FindFirstChild("Flashlight")
if Flashlight then
local player = game.Players.LocalPlayer
local backpack = player:WaitForChild("Backpack")
-- Check if the flashlight is not already in the player's backpack
if not backpack:FindFirstChild(Flashlight.Name) then
Flashlight:Clone().Parent = backpack
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)
2nd script for camera -------------------------------------------------------------------------------
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local function onEquip()
-- Change the camera mode to LockFirstPerson
player.CameraMode = Enum.CameraMode.LockFirstPerson
-- Hide the character's humanoid arms
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:RemoveAccessories()
end
end
end
local function onUnequip()
-- Change the camera mode back to Default
player.CameraMode = Enum.CameraMode.Default
-- Show the character's humanoid arms
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:BuildRigFromAttachments()
end
end
end
script.Parent.Equipped:Connect(onEquip)
script.Parent.Unequipped:Connect(onUnequip)
if you want the flashlight script i didnt make you can have it it might do as spotlight or something script.Parent.Activated:Connect(function()
if script.Parent.Handle.SpotLight.Enabled == true then
script.Parent.Handle.SpotLight.Enabled = false
script.Parent.Handle.Sound:Play()
else
script.Parent.Handle.SpotLight.Enabled = true
script.Parent.Handle.Sound:Play()
end
end)
script.Parent.Equipped:Connect(function()
script.Parent.Handle.SpotLight.Enabled = false
script.Parent.Handle.equip:Play()
end)
script.Parent.Unequipped:Connect(function()
script.Parent.Handle.equip:Play()
end)
this is the asset id of the flashlight/torch ____11242492137