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

How would I make a brick that increases leaderstat value when touched?

Asked by 5 years ago
Edited 5 years ago

I would like to create an obby and I have a script for the block that when you touch it your leaderstat increases whenever the player touches the brick! It is not working here's the script!

Part = script.Parent
name = script.Parent.Name
debounce = false
plr = game:WaitForChild('Players')
ok = plr.LocalPlayer
ls = ok.leaderstats.Stage







Part.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players")[Hit.Parent.Name] then 
      debounce = true
ls.Value = ls.Value +1


    end
end)
0
server script? or local? User#19524 175 — 5y
0
@incapaz, this must be a normal script but must be a LocalScript at the same time... lets consider its a Normal Script Leamir 3138 — 5y
0
@incapaz, this must be a normal script but must be a LocalScript at the same time... lets consider its a Normal Script Leamir 3138 — 5y

1 answer

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Hello, tightanfall!

Part = script.Parent
name = script.Parent.Name
debounce = false
plr = game:WaitForChild('Players')
--Removed thease 2 lines, considering this is a Normal Script and it don't have a link to Local Player



Part.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players")[Hit.Parent.Name] then 
    debounce = true
    ls = Game.Players:GetPlayerFromCharacter(hit.Parent) -- Gets the player based on the character
    ls.Value = ls.Value +1
    end
end)

Good Luck with your games

Ad

Answer this question