I've been trying to develop this for a while, still getting nowhere with, the attached script bellow doesn't work


script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if hit.Parent:FindFirstChild("Humanoid") then
		
		wait(1)
		print("HIT")
		if  player.leaderstats.Fish.Value == 0 then
			player.leaderstats.Fish.Value = player.leaderstats.Fish.Value - 0
			print("Adding0")
		 	wait(1)
		end
		
		else if  player.leaderstats.Fish.Value == 1 then
			player.leaderstats.Fish.Value = player.leaderstats.Fish.Value - 1
			print("Adding1")
			wait(1)
			
		
		end
		
	
	end
end)

Any help would be appreciated

3 comments

0

You cannot +/- values through local script. Try using remote events.+/- Values through script, Fire the client when the function 'hit player' is played.

0

can you specify what part of the script doesnt work?

0

try defining player after checking if humanoid exists.