Door = script.Parent
cooldown = 5 --How much time in seconds it takes for the door to open again. change if you wish.
value = false
function OnClicked()
if (value == false) then
value = true
end
local cloned = game.Lighting.Water:Clone()
game.Lighting.Water:Clone().Parent = game.Players.LocalPlayer.Backpack
Door.ClickDetector.MaxActivationDistance = 0
wait(cooldown)
value = false
Door.ClickDetector.MaxActivationDistance = 10
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)
I try clicking on Door to get the 'Water' gear but it says LocalPlayer is a nil value. How can I tell it to give the gear to whoever is clicking?
It works in the studio, but not in the real game.
Door = script.Parent
cooldown = 5 --How much time in seconds it takes for the door to open again. change if you wish.
value = false
function OnClicked(player)
if (value == false) then
value = true
end
local cloned = game.Lighting.Water:Clone()
game.Lighting.Water:Clone().Parent = player
cloned.Handle.Anchored = false
cloned.Handle.Locked = false
Door.CanCollide = false
Door.ClickDetector.MaxActivationDistance = 0
wait(cooldown)
value = false
Door.ClickDetector.MaxActivationDistance = 10
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)

2 comments
Add the argument ("player") at the start of your function it should work then. For example function OnClicked() would become function OnClicked(player) also change the clone parent to "player"
Okay, I put up the revised script. This time it doesn't give me the tool on studio either. And output doesn't show me what's wrong.