Coin collecting broken after dying

It’s fine now I found the problem, thanks for trying to help!

  1. What do you want to achieve? Keep it simple and clear!
    Stop coins breaking after resetting.
  2. What is the issue? Include screenshots / videos if possible!
    I can collect coins perfectly fine until resetting. There are no errors in the output.
    Discovered resetting stops this from working.

humanoid.Touched:connect(function(hit)
if hit.Name == “Coin” or hit.Name == “roofCoin” or hit.Name == “slapperCoin” or hit.Name == “parkCoin” or hit.Name == “swimingCoin” or hit.Name == “slideCoin” or hit.Name == “obbyCoin” then

		local db = hit:FindFirstChild("collect")
		if db.Value == true then
			db.Value = false
			hit.Transparency = 1
			script.Sound:Play()
			wait(1)
			hit:Remove()
1 Like

Could you add print statements to see where the error/problem lies inside your code?

1 Like

local playersss = game:GetService("Players").LocalPlayer
local charactor = playersss.Character or playersss.CharacterAdded:Wait()
local humanoid = charactor:WaitForChild("Humanoid")
humanoid.Touched:connect(function(hit)
	if hit.Name == "Coin" or hit.Name == "roofCoin" or hit.Name == "slapperCoin" or hit.Name == "parkCoin" or hit.Name == "swimingCoin" or hit.Name == "slideCoin" or hit.Name == "obbyCoin" then
			local db = hit:FindFirstChild("collect")
			if db.Value == true then
			print("Debounce FOUND")
			db.Value = false
			print("Debounce falsified")
				hit.Transparency = 1
				script.Sound:Play()
				wait(1)
			print("Coin is being removed")
			hit:Remove()
			print("Coin is REMOVED")	

Nothing was printed when it broke.
Confirmed resetting will stop this script working.

Instead of detecting touch on player humanoid, detect touch on coins and get player using hit.Parent

1 Like

I think I see the problem here. The code doesn’t have a end under it so it’s not able to work. Check any errors in the script analysis.
It should look like this

local playersss = game:GetService("Players").LocalPlayer
local charactor = playersss.Character or playersss.CharacterAdded:Wait()
local humanoid = charactor:WaitForChild("Humanoid")
humanoid.Touched:connect(function(hit)
	if hit.Name == "Coin" or hit.Name == "roofCoin" or hit.Name == "slapperCoin" or hit.Name == "parkCoin" or hit.Name == "swimingCoin" or hit.Name == "slideCoin" or hit.Name == "obbyCoin" then
			local db = hit:FindFirstChild("collect")
			if db.Value == true then
			print("Debounce FOUND")
			db.Value = false
			print("Debounce falsified")
				hit.Transparency = 1
				script.Sound:Play()
				wait(1)
			print("Coin is being removed")
			hit:Remove()
			print("Coin is REMOVED")	
        end
    end
end)
1 Like

There’s a few ends that aren’t shown here but are on my script. Thanks alot for trying!

1 Like
if hit.Name == "Coin" or hit.Name == "roofCoin" or hit.Name == "slapperCoin" or hit.Name == "parkCoin" or hit.Name == "swimingCoin" or hit.Name == "slideCoin" or hit.Name == "obbyCoin" then

The hit argument is attempting to find the Names that are inside those parts (If I recall correctly), you can use (As Brainy stated) hit.Parent to find the Character easily. if you’re trying to find the CoinNames inside the Character, just hit alone will only attempt to find the hit.Name inside that specific part “Left Leg” “Right Arm”, etc (You could also print out the hit variable to see what’s being touched)

1 Like

Im checking the names of the parts not the inside. But thanks for the help man!

Thanks for the suggestion, will do this as a last resort.