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.Head.Anchored = false 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
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