function onTouched(hit) human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then --I wanna change leaderstats here!! end end script.Parent.Touched:connect(onTouched)
Hey guys how do I change leaderstats with this script?
its name is stage.
local Player = game.Players:GetPlayerFromCharacter(hit.Parent) --"hit" is the object that hit the part that will change the Leaderstat. It is most likely the leg, so the parent of the leg would be your Character model. We are getting the Player that is connected to this model. if Player.leaderstats.Stage.Value == script.Parent.Name - 1 then -- ensures that if they had skipped one checkpoint, they would not be able to progress. if human.Health ~= 0 then --ensures that the person can't progress if their limb/body part had just landed on the part by chance when they had died. Player.leaderstats.Stage.Value = script.Parent.Name --Changing the value of the stat. The script's parent (the brick) must be named the stage value you want it to be.
This should work, sorry about explaining in the code, it's just the font is smaller lol. All that would go under the if human ~= nil then
statement
On Touched:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.CURRENCYNAME.Value = player.leaderstats.CURRENCYNAME.Value + AMOUNT end end) On Clicked: script.Parent.ClickDetector.MouseClick:Connect(function(player) player.leaderstats.CURRENCYNAME.Value = player.leaderstats.CURRENCYNAME.Value + AMOUNT end)
Thanks Me Later