Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with my magicsphere?

Asked by 10 years ago

My magicsphere is supposed to fire out a lot of spheres and then if a player touches the sphere they die.This is the script

Player = game.Players.LocalPlayer
LazerSphear = script.Parent
Mana = 10
mouse = Player:GetMouse()
function Magic()
    Mana = Mana -0.6
    for MagicAffects = 1,20 do
        script.Parent.Handle:Clone()
        if script.Parent.Handle:FindFirstChild("Humanoid") ~= nil and Humanoid.Health not == 0 then
            Humanoid.Health = 0
        end
    end
end
0
Is this the whole script? What calls `Magic`? BlueTaslem 18071 — 10y
3
Line 9: Attempt to call 'Humanoid' (a nil value) Line 10: Attempt to call 'Humanoid' (a nil value) TheeDeathCaster 2368 — 10y
1
This is the whole script BlueTaslem.I forgot to call the function iluvmaths1123 198 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

You never assigned the variable "Humanoid" to anything. You could do

local Humanoid = script.Parent.Handle:FindFirstChild("Humanoid")
if Humanoid and Humanoid.Health ~= 0 then
Humanoid.Health = 0
end
Ad

Answer this question