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

not a valid member?

Asked by 9 years ago

Alright so I wrote this script that make's orbs appear behind the player in a loop and when you click on someone the orbs fly towards them. It pretty much works how I want it with two exceptions that I can't seem to fix. The first is that sometimes after the orbs launch there's an error message in the output that says "rover is not a valid member of Part" and the orbs won't launch anymore after that unless I reset. The second problem is that I keep receiving this error "Humanoid is not a valid member of Workspace". I've tried fixing these errors but I'm at a loss so any help is appreciated. Here's my script :).

Player = game.Players.LocalPlayer

local character = Player.Character
if not character or not character.Parent then
    character = Player.CharacterAdded:wait()
end
wait()

Player = game.Players.LocalPlayer.Character
Number = Instance.new("NumberValue")
Number.Name = "dirc"
f2 = 25/4
tim = 1/100000
mouse = game.Players.LocalPlayer:GetMouse()
enabled = script.Parent.Switch


function go(Part)
    if not Part:IsDescendantOf(Player) then

    if Part.Parent.Humanoid == nil then
    print("not verified")
    end 

    if Part.Parent.Humanoid then
    print("verified")
    wait(tim)
    Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health-5
    end

    end
end

lunch = true
function launcher()
 if not lunch then
        return
  end
lunch = false
    print("get em")
    x = Player:GetChildren()
    for i= 1, #x do
    if x[i].Name == "Aura" then
    wait(0.1)
    x[i].Anchored = false
    x[i].Touched:connect(go)
    local rover = x[i].rover
    mouse.TargetFilter = game.Workspace.Baseplate
    x[i].rover.Target = mouse.Target
    x[i].rover:Fire()
    x[i].rover.ReachedTarget:connect(function()
        game.Debris:AddItem(x[i], 0.01)
    end)
    end
    end
wait(2)
lunch = true
end

function launch(spect)
if spect.dirc.Value == 1 then
for i = 2, f2*2 do
    wait(tim)
    spect.CFrame = Player.Torso.CFrame*CFrame.new(i/5, 0, i/10)
    mouse.Button1Down:connect(launcher)
end
end

if spect.dirc.Value == 2 then
for i = 2, f2*2 do
    wait(tim)
    spect.CFrame = Player.Torso.CFrame*CFrame.new(-i/5, 0, i/10)
    mouse.Button1Down:connect(launcher)
end
end

if spect.dirc.Value == 3 then
for i = 2, f2*2 do
    wait(tim)   
    spect.CFrame = Player.Torso.CFrame*CFrame.new(0, i/5, i/10)
    mouse.Button1Down:connect(launcher)
end
end

if spect.dirc.Value == 4 then
for i = 2, f2*1.5 do
    wait(tim)
    spect.CFrame = Player.Torso.CFrame*CFrame.new(i/5, i/5, i/10)
    mouse.Button1Down:connect(launcher)
end
end

if spect.dirc.Value == 5 then
for i = 2, f2*1.5 do
    wait(tim)
    spect.CFrame = Player.Torso.CFrame*CFrame.new(-i/5, i/5, i/10)
end
end

end

function activ ()
enabled = true
while enabled do
for i = 1, 5 do
    wait(tim)
    local spec = Instance.new("Part", Player)
    local rocket = Instance.new("RocketPropulsion", spec)
    rocket.Name = "rover"
    rocket.ThrustP = 80000
    spec.Name = "Aura"
    spec.Anchored = true
    spec.TopSurface = "Smooth"
    spec.BottomSurface = "Smooth"
    spec.BrickColor = BrickColor.new("New Yeller")
    spec.Shape = "Ball"
    spec.CanCollide = false
    spec.Size = Vector3.new(1, 1, 1)
    spec.CFrame = Player.Torso.CFrame*CFrame.new(0, 0, .5)
    local Num = Number:Clone()
    Num.Parent = spec
    Num.Value = i
    launch(spec)
    game.Debris:AddItem(spec, 6)
end
end
end

function non()
enabled = false
print("Off")
    Player.Humanoid.WalkSpeed = 16
end

script.Parent.On.MouseButton1Click:connect(activ)
script.Parent.Off.MouseButton1Click:connect(non)

Answer this question