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

Does someone know how to do this?

I want a script that gives points example:if i clicked a brick it would give me 10 points

8 comments

0

Like 10 PlayerPoints or would it be a Stat in Leaderstats?

0

leaderstats

0

example in a game theres a leaderboard and the cash name is ''points'' if they clicked a model or brick they would get 10 points

0

You do know how to create leaderstats though, right? If not then my answer would be pointless.

0

ik how to do that

0

i just dont know the hard stuff of scripting

0

Oh okay! Don't worry, click detectors are easy

0

ok

1 answer

You'll have to use a ClickDetector located inside a part. Insert a script into the part too.

local click = script.Parent:FindFirstChild("ClickDetector")

This creates a variable for the ClickDetector.

click.MouseClick:Connect(function(plr)

end)

This is the built in ROBLOX function for MouseClick with "plr" as the argument. It basically says when the part is clicked, do stuff.

if game.Players:FindFirstChild(plr.Name) then
		game.Players:FindFirstChild(plr.Name).leaderstats.Coins.Value = game.Players:FindFirstChild(plr.Name).leaderstats.Coins.Value + 10

This sees if the player exists in the game, and if the player does, it adds 10 coins to their current amount of coins. You can change Coins to whatever value you'd like, as long as it exists.

All combined together, is the following.

local click = script.Parent:FindFirstChild("ClickDetector")


click.MouseClick:Connect(function(plr)
	if game.Players:FindFirstChild(plr.Name) then
		game.Players:FindFirstChild(plr.Name).leaderstats.Coins.Value = game.Players:FindFirstChild(plr.Name).leaderstats.Coins.Value + 10
		-- Use variables to make it shorter
	end
end)

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