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
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 = Instance.new('IntValue')
Poisoned.Name = 'HasEaten'
Poisoned.Parent = Player
Poisoned.Value = 0
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 = Instance.new("IntValue")
poisoned.Name = "HasEaten"
poisoned.Value = 0
poisoned.Parent = player