I need script what check when player joined in my obby if is example Prestige 5 in leaderboard and give him a some item. If is 6 Prestige other item + etc.
I show “example” what i find and try but this now work!:
game.Players.PlayerAdded:connect(function(player)
player:WaitForChild("leaderstats") -- Make sure leaderstats is there
if player.leaderstats.Prestige.Value >= 5 then -- Check level
game.ServerStorage.Snowball:clone().Parent = player:WaitForChild("Backpack")
-- Clone in their backpack
game.ServerStorage.Snowball:clone().Parent = player.WaitForChild("StarterGear") -- Clone in their starter gear so they spawn with it everytime
end
end)
You should use DataStore instead, and you are not setting leaderstats when the player joins. Also like @Med367367 said, maybe the Presitige Value is a string. You can fix this with tonumber()
Hope this helps
game.Players.PlayerAdded:connect(function(player)
player:WaitForChild("leaderstats") -- Make sure leaderstats is there
if tonumber(player.leaderstats.Prestige.Value) >= 5 then -- Check level
game.ServerStorage.Snowball:clone().Parent = player:WaitForChild("Backpack")
-- Clone in their backpack
game.ServerStorage.Snowball:clone().Parent = player.WaitForChild("StarterGear") -- Clone in their starter gear so they spawn with it everytime
end
end)
Ok tryed now, console not said any error. And still backpack dont have this tool.
Btw tool normaly working and when i manualy drag to StarterPack be there in game so dont know.
It is normal that if you put them in the Starter Pack it does not appear immediately, Here is the function of StarterPack.StarterPack | Documentation - Roblox Creator Hub
For doing this simple, just make the player re-spawn after
if tonumber(player.leaderstats.Prestige.Value) >= 5 then -- Check level
player.CharacterAdded:Connect(function(obj)
local tool = game.ServerStorage.Snowball:clone()
tool.Parent = WaitForChild("Backpack")
end)
end
This should add the tool everytime they die or spawn
Hope this helps
This will work but if there are a lot of tools to verify this is include a lot of “if” and this can by bad at a certain time. I think is more a good idea to set it in the player StarterGear but this is only my opinion
I am pretty sure this is incorrect. StarterGear and StarterPack are both on the server (although I believe only StarterGear is replicated to the client). StarterGear is basically a starter pack only for the Player it is parented to. StarterPack gives every player in the game the tools in it when their character respawns.
I sending here gamepass script part what i used to check if Product buyed.
Maybe in this script you find some what working better to backpack this.
This script use “lighting” part as Storage
Here is example:
local Lighting = game:GetService("Lighting")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 0000000 --Put the ID of the asset here
local toolNames = {"SpeedCoil"} --Must be in lighting
local toolsParent = Lighting
local function onPlayerAdded(player)
local function onCharacterAdded(character)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
for i = 1, #toolNames do
local tool = toolsParent:FindFirstChild(toolNames[i])
if tool then
local clone = tool:Clone()
clone.Parent = player.Backpack
end
end
end
end
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:Wait()
player:WaitForChild("leaderstats") -- Make sure leaderstats is there
if player.leaderstats.Prestige.Value >= 5 then -- Check level
game.ServerStorage.Snowball:clone().Parent = player:WaitForChild("Backpack")
-- Clone in their backpack
game.ServerStorage.Snowball:clone().Parent = player.WaitForChild("StarterGear") -- Clone in their starter gear so they spawn with it everytime
end
end)