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

Does someone know how to do this? [closed]

Asked by 7 years ago
Edited 7 years ago

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

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

Closed as Not Constructive by lukeb50, PyccknnXakep, abnotaddable, and DanzLua

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)
Ad