I am trying to give items as players get to certain levels. I am stuck on the code, and can't seem to get the Player and player leader stats player level to call properly
This is Code I have been working on Thanks for the help in advance.
local player = game.Players:GetPlayers() local leaderstats = player.leaderstats() local level = leaderstats.level() local tool = game.ServerStorage.LinkedSword function onPlayerSpawned(player) if player:Level (level) >= 1 then tool:Clone().Parent = player.Backpack end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() onPlayerSpawned(player) end) end)
That script was all over. Many unnecessary parentheses. This script should work just fine.
game.Players.PlayerAdded:connect(function(player) player:WaitForChild("leaderstats") -- Make sure leaderstats is there if player.leaderstats.level.Value >= 0 then -- Check level game.ServerStorage.LinkedSword:clone().Parent = player.Backpack -- Clone in their backpack game.ServerStorage.LinkedSword:clone().Parent = player.StarterGear -- Clone in their starter gear so they spawn with it everytime end end)
Big thanks to dirk2999 Got it working on the one item. I had to Wait to the script. Looks like this now
game.Players.PlayerAdded:connect(function(player) player:WaitForChild("leaderstats") -- Make sure leaderstats is there if player.leaderstats.Level.Value >= 0 then -- Check level game.ServerStorage.LinkedSword:clone().Parent = player:WaitForChild("Backpack") -- Clone in their backpack game.ServerStorage.LinkedSword:clone().Parent = player.WaitForChild("StarterGear") -- Clone in their starter gear so they spawn with it everytime end end)
Not tonight I can start adding more items and levels. I tried to give you an upvote but it won't let me I don't have 25 rep yet.