Coin Script not working as intended

Because the other guy said the parent thats touching it is nil its not an humanoid so its weird.

Try making it not touch the ground and see if it registers the touch.

Oh i get it the script is erroring because it doesnt know who is the player this is the best way i can explain.

yo did u figure out the problem why its not giving the player points

Okay. ill try it to see extra sentence because I need more letters in sentence lol

no, not really and also the client is not figuring out who’s the character.

maybe put a player in the function like this function(player)

But the coin touches a body part, not the player.

look

local Coin = script.Parent
local Touched = false

print('Code: Running', Coin)

Coin.Touched:Connect(function(Hit)
	if Touched then
		return print('Part already touched.')
	end

	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	print(Player)

	if Player then
		print('Player found - Giving coins')
		Touched = true
		Player.leaderstats.Coins.Value += 1
		Coin.Transparency = 1
		wait(60)
		Coin.Transparency = 0
		Touched = false
	end
end)

18:19:05.897 Code: Running Coins - Server - Script:4
18:19:06.198 :arrow_forward: nil (x2) - Server - Script:12

Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value +1

plus ur script is actually a local script btw
actually localScripts can be used for control the client-objects and help with guis

wait this script is really simple what if it works: local Part = script.Parent

Part.Touched:Connect(function(player)
if player.Parent:FindFirstChild(“Humanoid”) then
local playerCoins = player.leaderstats.coins
playerCoins.Value = playerCoins.Value + 1

end

end)

Try it

''a script you mean??" hmm?? its script. i evan tried local scripts.

i mean you will need to add a localscript

Doesnt Work No Type of error. eh.

I wouldn’t use ‘Touched’ as your DB.

Try ‘local playerCoins = player.leaderstats.Coins’

Dude Im dumb I was touching the wrong coin and was touching the other one the whole time. Sorry.

2 Likes

:man_facepalming:

That just describes the whole situation.