I have this script, but it only works when I test it, and not in the real game...
while true do wait(27) game.ServerStorage["LinkedSword"]:Clone().Parent = game.Players.LocalPlayer.Backpack wait(58) end
Please help! I've looked everywhere but I get the same answer, and it never works!
Please use code block in the future
Your problem is most likely that you are attempting to index the LocalPlayer
from a server script.
Try parenting this code into StarterPack from a LocalScript and it should work.
But note - it will make duplicate swords so you should probably add a check. And localscripts can't access ServerStorage so would need to put the tool in ReplicatedStorage
local sword = game.ReplicatedStorage["Linked Sword"]; local plr = game.Players.LocalPlayer; while true do wait(27) if not plr.Backpack:FindFirstChild(sword.Name) then sword:Clone().Parent = plr.Backpack; end wait(58) end
Alternatively, if you want the whole server to recieve swords at the same time, you can use a generic for loop and iterate through the players from a script in Workspace.
local sword = game.ServerStorage["Linked Sword"]; while true do wait(27) for _,v in next,game.Players:GetPlayers() do if not v.Backpack:FindFirstChild(sword.Name) then sword:Clone().Parent = v.Backpack; end end wait(58) end