Hello, I am pretty new at scripting and I am trying to make a team changer script for my game and it is not changing the team or leaderstat value at all like intended and I have tried looking for solutions but have found none so if you could please help me that would be great.
Here is the script:
local restocker = game.Teams.Restocker
script.Parent.MouseButton1Click:Connect(function(plr)
if plr.leaderstats.XP.Value >= 1 then
plr.leaderstats.XP.Value = plr.leaderstats.XP.Value
plr.Team = restocker
end
end)
MouseButton1Click doesn’t return the player. You might as well use the local player by defining it, since the person who clicked the button will always be the client.
local player = game.Players.LocalPlayer
local restocker = game.Teams.Restocker
script.Parent.MouseButton1Click:Connect(function()
local XP = player:WaitForChild("leaderstats"):WaitForChild("XP")
if XP.Value >= 1 then
XP.Value = XP.Value
player.Team = restocker
end
end)