Hi all.
After several months I thought I’d progressed quite nicely from a noob to ‘intermediate’ level, but it seems I’ve hit a brick wall
I’m using FE to restore a player’s health to 100 when he/she picks up a pill bottle. My code works perfectly … it restores the player to full health as designed. HOWEVER, the moment I test this with two or more players, the script restores the health of ALL players. I need it to restore ONLY the player who picked-up the bottle.
Here’s my code:
Localscript:
if instance.Name == "PillBottle" then
local ss = instance
ss.Touched:Connect(function(plr)
PillBottle:FireServer()
ss:Destroy()
end)
end
ServerScript:
PillBottle.OnServerEvent:Connect(function(plr)
if not plr.Character then
print("waiting for character")
plr.CharacterAdded:wait();
local char = plr.Character
else
local char = plr.Character
local human = char:FindFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.MaxHealth
end
end
Like I said, the script IS working, so I’m confident all declarations at the head of the script are fine. It’s just the ‘multi-player’ issue that’s messing with me. I have no idea why this is restoring ALL players’ health. I’m guessing it’s just something dumb and obvious that I’m not ‘getting’. Any help will be truly appreciated!!