Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

3 comments

0

server script? or local?

0

@incapaz, this must be a normal script but must be a LocalScript at the same time... lets consider its a Normal Script

0

@incapaz, this must be a normal script but must be a LocalScript at the same time... lets consider its a Normal Script

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.