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.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

An error keeps popping up even though it appears nothing is wrong?

Asked by 11 days ago
Edited 11 days ago

So I was creating a script, Full code is now included, sorry.

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local Rdy = tool:WaitForChild("Ready")
local beam = tool:WaitForChild("Beam")
local smoke = beam:WaitForChild("Smoke")
local rel = beam:WaitForChild("Reloading")
local fir = beam:WaitForChild("Blast")
local bep = beam:WaitForChild("Beep")
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
local DS = game:GetService("Debris")

tool.Activated:Connect(function()
    if Rdy.Value == true then
        Rdy.Value = false
        rel:Play()
        beam.BrickColor = plr.TeamColor
        wait(4.5)
        for a = 1,50 do
        local bullet = Instance.new("Part",workspace)
        fir:Play()
        bullet.Size = Vector3.new(.1,.1,1)
        bullet.BrickColor = plr.TeamColor
        bullet.Material = "Neon"
        bullet.CFrame = beam.CFrame + Vector3.new(0,0,-1.5)
        bullet.Velocity = beam.CFrame.lookVector * 250
        bullet.Touched:Connect(function(hitpart)
            if hitpart.Parent:FindFirstChildOfClass("Humanoid") then
                local h = hitpart.Parent:FindFirstChildOfClass("Humanoid")
                local hplayer = game.Players:GetPlayerFromCharacter(hitpart.Parent)
                if hplayer.TeamColor ~= plr.TeamColor then
                print("Bullet hit "..hitpart.Parent.Name.."!")
                h:TakeDamage(2)
                end
            end
            DS:AddItem(bullet,2)
        end)
        end
        beam.BrickColor = BrickColor.new("Really black")
        wait(10)
        beam.BrickColor = BrickColor.new("Br. yellowish orange")
        for a = 1,5 do
            bep:Play()
            wait(.5)
        end
        wait(1)
        beam.BrickColor = BrickColor.new("Shamrock")
        Rdy.Value = true
    end
end)

Nothing seems wrong in it, yet whenever the bullet touches things it just displays " Players.gamemaster60788.Backpack.Power Cannon.Main:28: attempt to index field 'Parent' (a nil value)"

Any help?

0
Which ones line 28? royaltoe 1796 — 11d
0
There is no Line 28 Sonnenroboter 310 — 11d
0
Show your full code, please. BashCaster 2371 — 11d
0
I believe it's no 2 because it's the very first time parent is mentioned but a confirmation would be nice. the error wouldn't make sense anyway tbh GGRBXLuaGG 332 — 11d
View all comments (2 more)
0
Show more of your code so we can see line 28 because in the error message you showed us it says there is a problem on line 28 BriskyDev 4 — 11d
0
Added the full code, line 28 was actually line 11 when I only put the small part gamemaster60788 9 — 11d

Answer this question