I want a script that gives points example:if i clicked a brick it would give me 10 points
COMMUNITY QUESTION
Does someone know how to do this?
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.

8 comments
Like 10 PlayerPoints or would it be a Stat in Leaderstats?
leaderstats
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
You do know how to create leaderstats though, right? If not then my answer would be pointless.
ik how to do that
i just dont know the hard stuff of scripting
Oh okay! Don't worry, click detectors are easy
ok