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

i want this to give a leaderstat when a part touches another part?

its ment to add +1 to score

script.Parent.Touched:connect(function(hit) if hit.Parent.Name == "RedCube" or "BlueCube" then Player.leaderstats.Score.Value = Player.leaderstats.Score.Value + 1 end end)

1 answer

Seems like you're new to lua, so in ServerScriptService make a script;

game.Players.PlayerAdded:connect(function(plr) -- when the player joins the game
	local leaderstats=Instance.new("Configuration") --make folder of leaderstats
	leaderstats.Name="leaderstats" --define the name
	leaderstats.Parent=plr -- sets the leaderstats in the player
	
	local score=Instance.new("NumberValue") --makes the score value
	score.Name="Score" -- the name
	score.Parent=leaderstats --sets it so you can see the score on the leaderboard
end)

And in the part in the workspace, put the script;

script.Parent.Touched:connect(function(hit)  -- when something touches the part
	if hit.Name=="Left Leg" or "Right Leg" then --if its the leg of the player
		local Player=game.Players:GetPlayerFromCharacter(hit.Parent) -- find the player (using the character)
		Player.leaderstats.Score.Value = Player.leaderstats.Score.Value + 1 -- adds the point
	end 
end)

Thanks!

1 comment

0

So, only R6 support, not R15 support?

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