Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I give a player a tool based off of a leaderstat?

Asked by
pb_ub 0
2 years ago

I am trying to make it so a player gets a tool based off of their leaderstat. Basically I have a leaderstat called "Style" and based off of the value of that leaderstat it should give the player a tool based off of this. I've tried many things and I am about two months into roblox scripting.

here is my code: local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player) local leaderstats = player:FindFirstChild("leaderstats") local style = leaderstats and leaderstats:FindFirstChild("Style")

if style then
    if style.Value == nil then
        style.Value = 0
    end

    if style.Value == 0 then
        local backpack = player:WaitForChild("Backpack")
        local cloneTool = game.ServerStorage.Combat:Clone()
        cloneTool.Parent = backpack
    end

    if style.Value == 1 then
        local backpack = player:WaitForChild("Backpack")
        local cloneTool = game.ServerStorage.Taekwondo:Clone()
        cloneTool.Parent = backpack
    end

    if style.Value == 2 then
        local backpack = player:WaitForChild("Backpack")
        local cloneTool = game.ServerStorage.Boxing:Clone()
        cloneTool.Parent = backpack
    end
end

end)

Answer this question