IntValue Not working

Hey Everyone,
I am making a poison script for my players when they eat the apple. However it’s not working.
Here is my script:

for i,v in pairs(game.Players:GetPlayers()) do
	if v.Character and v.Character.Humanoid.Health > 0 then
		print('has a character!')
		if v:FindFirstChild('HasEaten') then
			v.Character.Humanoid.Health = v.Character.Humanoid.Health - 60
			print('Not found')

It’s printing Not Found. I have checked and the intValue is in the player. This is my other script:

Player = game.Players.LocalPlayer

	local Poisoned ='IntValue')
	Poisoned.Name = 'HasEaten'
	Poisoned.Parent = Player
	Poisoned.Value = 0

There are no errors. Thank you for any help :smiley:

IntValue exists on the client side, so it will not replicate to the server. HasEaten can also be a BoolValue by what I see by your code. I would also make BoolValue when the player is added.

Lmk if u have any issues

As ColeBots said, this is a client side problem. I believe that the IntValue is being cloned only locally. Whenever you are playtesting the game, you are viewing what a client would see. If you really want to see what is going on, go to test on the top of studio when playtesting and click the part where it says Current: Client. It will switch you to a server view where you will not see what is going on. I believe that this problem could be solved by creating the “Poisoned” value itself on the server using a remoteEvent called “Insert” in replicatedStorage (basically create an event called Insert in ReplicatedStorage). The server-side script handling the creation should be separate from the script checking for the poisoned value.

New server side script you need to insert:

local poisoned ="IntValue")
poisoned.Name = "HasEaten"
poisoned.Value = 0
poisoned.Parent = player


New client script:

Player = game.Players.LocalPlayer


1 Like