✓ Accepted answer
You are only able to access the LocalPlayer through a LocalScript, otherwise the server script doesn't know what player you are referring to when you use LocalPlayer. If you want to check every player instead with a server script, you can use PlayerAdded:
game.Players.PlayerAdded:Connect(function(Plr)
local ClassicSword = Plr.Backpack:WaitForChild("ClassicSword",5)
if ClassicSword then
print("it works")
end
end)
If you wanted to print when a classic sword was added to the backpack instead, you could do something like this with ChildAdded:
game.Players.PlayerAdded:Connect(function(Plr)
Plr.Backpack.ChildAdded:Connect(function(Child)
if Child.Name == "ClassicSword" then
print("sword was added")
end
end)
end)
The PlayerAdded and ChildAdded events fire every time a player joins/child is added.
Hope this helps!
1 comment
Thanks