I put a clickdetector in a part and the script is a normal script with the part as its parent as well, how would I define player to insert a leaderstats value into the player?
local cldet = script.Parent.ClickDetector
local players = game:GetService("Players")
cldet.MouseClick:Connect(function()
local player = ???
local ls = player:WaitForChild("leaderstats")
local clicks = ls:FindFirstChild("Clicks")
local multiplier = ls:FindFirstChild("multiplier")
clicks.Value = clicks.Value + (3*multiplier.Value)
script.Parent:Destroy()
end)
The player that clicks the detector will be in the .MouseClick. put player as the parameter of your function and then create a leaderstat for that player
local cldet = script.Parent.ClickDetector
local players = game:GetService("Players")
cldet.MouseClick:Connect(function(player)
local ls = player:WaitForChild("leaderstats")
local clicks = ls:FindFirstChild("Clicks")
local multiplier = ls:FindFirstChild("multiplier")
clicks.Value = clicks.Value + (3*multiplier.Value)
script.Parent:Destroy()
end)