New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# Why won't my humanoid get healed?

Hello! I am making a "Little sister" Form bioshock in which when clicked, it will heal you! I think when I use the function: function onClicked(click) That makes the click part of it usable in a script like it is below. I'm not sure what to call that.

function onClicked(click)
local human = click.Parent:findFirstChild("Humanoid")
human.Health = 100
--Below is fine, above is not--
child = script.Parent.Parent
child:FindFirstChild("Left Arm").Anchored = false
child:FindFirstChild("Left Leg").Anchored = false
child.Part.Anchored = false
child:FindFirstChild("Right Arm").Anchored = false
child:FindFirstChild("Right Leg").Anchored = false
child.Torso.Anchored = false
child.Humanoid.Health = 0
child.Name = "LittleSister (Harvested)"
game.Players.LocalPlayer.PlayerGui.HarvestGui.Frame.Visible = true
wait(2)
game.Players.LocalPlayer.PlayerGui.HarvestGui.Frame.Visible = false

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)



The problem is the 'human' part is not found. here is the output: 13:26:50.992 - Workspace.Sister_Vent.LittleSister.Torso.Script:3: attempt to index local 'human' (a nil value) 13:26:50.993 - Stack Begin 13:26:50.994 - Script 'Workspace.Sister_Vent.LittleSister.Torso.Script', Line 3 Any help?

~Minikitkat

1
Goulstem 8057
4 years ago

The problem here is that the Clicked Event returns the player who clicked, not the Character.

To fix this..

function onClicked(plr)
if plr and plr.Character then
plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
local child = script.Parent.Parent
for i,v in pairs(child:GetChildren()) do
if v:IsA('BasePart') then
v.Anchored = false
end
end
child.Humanoid.Health = 0
child.Name = "LittleSister (Harvested)"
plr.PlayerGui.HarvestGui.Frame.Visible = true
wait(2)
plr.PlayerGui.HarvestGui.Frame.Visible = false
end
end)


This should be a server script

0
Thanks! This worked! I had to modify it though. All I needed was the health part I just thought it would be better to see the whole script. Thanks! minikitkat 687 — 4y
0
I just modified the part where you unanchor all the limbs, what I posted should work but if it didn't then sorry. Have fun coding(: Goulstem 8057 — 4y