Im trying to make a script so when you click on the cookie it gives you the cookie in your starter backpack ive tried several times and its failing can anyone help me? ive tried this script with a click
detector dist = 10
function onClicked()
local p = game.Players:GetChildren()
for i = 1, #p do
if (p[i].Name ~= script.Owner.Value) then
if (p[i].Character.Torso.Position - script.Parent.Position).magnitude < dist then
game.Lighting.Cookie:clone().Parent = p[i].Backpack
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment
Man Thanks so much I think i over thaught it but thanks alot simple script worked