Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you get a player from a server script with no events?

Hey, so I'm trying to make a hitbox thing damage IDK what to call it but anyways the script is meant to do this :D

If a player clicks a part 5 times they make the part get deleted and they receive currency/Money

But here's the problem how do I award a player with Money?

local HitValue = 0

script.Parent.ClickDetector.MouseClick:Connect(function()
	
	HitValue = HitValue + 1
	
	print(HitValue)
end)

while HitValue < 10 do
	wait()
	if HitValue == 5 then
		script.Parent.Parent.TestingWoodPart:Destroy()
	end
end

2 answers

✓ Accepted answer
local HitValue = 0
local player

script.Parent.ClickDetector.MouseClick:Connect(function(detected_player)

    HitValue = HitValue + 1
    print(HitValue)
    player = detected_player

end)

while HitValue < 10 do
    wait()
    if HitValue == 5 then
        script.Parent.Parent.TestingWoodPart:Destroy()
	player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1 --you can modify "Money" with the correct name or the value
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.