I'm making a brick so when you click it, then it gives you a leaderstat cash. I just cant get it working to who clicked the brick.
I have a code that'll get the player if you TOUCH it, like collide.
local ting = 0 --debouncer
function onTouched(hit)
if ting == 0 then --debounce check
ting = 1 --activate debounce
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats")
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild("PartsClicked")
cash.Value = cash.Value +1
end
end
ting = 0 --remove debounce
end
end
script.Parent.Touched:connect(onTouched)
So can maybe someone help me convert this into the same thing but when you click it? I have the clickdetector and everything in it. Thank you.
