This script works in solo mode, but not in online mode. I tried putting it in a local script for the LocalPlayer to work, but the script doesn't execute.
regenTime = 5
model = script.Parent.Parent.Parent.Parent.Parent
Touched = false
script.Parent.Touched:connect(function(hit)
if Touched == false then
Touched = true
wait()
backup = model:Clone()
backup.Parent = game.ReplicatedStorage
model:Destroy()
opened = game.ReplicatedStorage["OpenedChest1"]:Clone()
opened.Parent = game.Workspace
wait(1.4)
opened["Unknown Fruit"]:Destroy()
player = game.Players:FindFirstChild(hit.Parent.Name)
lighting = game.Lighting:GetChildren()
fruit = lighting[math.random(1, #lighting)]
if player and fruit then
fruit:Clone().Parent = player.Backpack
end
wait(2.5)
opened:Destroy()
wait(regenTime)
backup.Parent = game.Workspace
Touched = false
end
end)
Anything I'm not familiar about? *Edited script

3 comments
still not working
To teach the unknowing, you have to start from the beginning.
You know, "Still not working" doesn't really help me help you.