I want a script that gives points example:if i clicked a brick it would give me 10 points
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)
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?