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

i made a gun but the damge age script for 3 sec then it stopes how do i fix?

Asked by 6 years ago
Edited 6 years ago

here is error attempt to index field 'Parent' (a nil value)

-- the script
script.Parent.Touched:Connect(function(hit)

    script.Parent.CanCollide = true
    if hit.Parent:FindFirstChild("Humanoid")

        then hit.Parent.Humanoid.Health  = hit.Parent.Humanoid.Health - 2
    script.Parent:remove()

    end
end)

the script i am using for it

local play = game.Players.LocalPlayer
local char = play.Character
local mouse = play:GetMouse()
local fire = true


script.Parent.Parent.Activated:Connect(function()
    while fire == true do
        wait()


    local clone = game.Workspace.lazer:Clone()
    local b = game.Workspace.dmg.Gun:Clone()
local r = game.Workspace.dmg.flame:Clone()
    r.Disabled = false
    b.Disabled = false
    local x =  Instance.new("BodyVelocity",clone)
    x.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    x.Velocity = mouse.Hit.lookVector* 90
    clone.Parent = game.Workspace
    clone.Position = script.Parent.Position *Vector3.new(1,0,0)
    r.Parent = clone
    b.Parent = clone
    end
end)
script.Parent.Parent.Deactivated:Connect(function()
    fire = false
    wait(1)
    fire = true
end)
0
:remove is deprecated. Use :Destroy() xPolarium 1388 — 6y
0
Also is the top code in a script and the bottom a local script? xPolarium 1388 — 6y

1 answer

Log in to vote
0
Answered by
exvient 30
6 years ago

The :Remove() feature is deprecated, use :Destroy() instead.

Make sure to have the bottom script in a LOCALSCRIPT to ensure that it can run properly. If you have any more questions please feel free to ask here again on Scripting Helpers.

0
Don't copy someone's comments, it won't help the asker User#20388 0 — 6y
Ad

Answer this question