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

It says Attachment is not a valid member of part?

Asked by
Neon_N 104
5 years ago

I put my part named "FireBall" in ReplicatedStorage. Inside "FireBall" there is Attachment but the Output says "Attachment is not a valid member of part."

I will put part of my script below. Tell me if you need the whole script to answer me.

-- Variables --
local Remote = ReplicatedStorage.FireBallEvent
local FireBall = ReplicatedStorage.FireBall

Remote.OnServerEvent:Connect(function(plr, Mouse)
 if not ServerDebounces[plr] then
  ServerDebounces[plr] = true

-- Settings --  

  local Char = plr.Character or plr.CharacterAdded:Wait()

  local FireBallClone = FireBall:Clone()

 local Enemy = Hum.Parent.Humanoid
    Enemy:TakeDamage(Damage)
    BodyVelocity:Destroy()
    FireBallClone.Attachment.Effect.Speed = NumberRange.new(8,8)
    wait(1)
    FireBallClone.Attachment.Effect.Enabled = false
    FireBallClone.Attachment.SmokeEffect.Enabled = false
    wait(1)
    FireBallClone:Destroy()

I don't know why it says that Attachment is not a valid member of part.

Effect and SmokeEffect is inside Attachment. and Attachment is inside the FireBall and FireBallClone is cloned FireBall. So Attachment is supposed to be inside FireBallClone isn't it?

0
The problem's that the script loaded before the attachment was there; to fix this issue, simply use `WaitForChild`. :) TheeDeathCaster 2368 — 5y
0
on line 2 add repeat wait() until game.Players.LocalPlayer greatneil80 2647 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

As TheeDeathCaster said, the script loaded before the attachment did. Add local attachment = FireBallClone:WaitForChild("Attachment") somewhere and replace FireBallClone.Attachment on the other lines with attachment. And here's your script that should be fixed by now.

-- Variables --
local Remote = ReplicatedStorage.FireBallEvent
local FireBall = ReplicatedStorage.FireBall

Remote.OnServerEvent:Connect(function(plr, Mouse)
 if not ServerDebounces[plr] then
  ServerDebounces[plr] = true

-- Settings --  

  local Char = plr.Character or plr.CharacterAdded:Wait()

  local FireBallClone = FireBall:Clone()
local attachment = FireBallClone:WaitForChild("Attachment")

 local Enemy = Hum.Parent.Humanoid
    Enemy:TakeDamage(Damage)
    BodyVelocity:Destroy()
    attachment.Effect.Speed = NumberRange.new(8,8)
    wait(1)
    attachment.Effect.Enabled = false
    attachment.SmokeEffect.Enabled = false
    wait(1)
    FireBallClone:Destroy()
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Put these two in StarterPack:

For pressing key: (Local Script)

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RemoteEvent = game.Workspace.Fired
local UIS = game:GetService("UserInputService")

local Debounce = false

UIS.InputBegan:Connect(function(Input, gameProcessed)
    if Input.KeyCode == Enum.KeyCode.F and gameProcessed == false then
        if Debounce == true then return end
        Debounce = true
        RemoteEvent:FireServer()
        wait(0.5) -- Change the interval between each fireball
        Debounce = false
    end
end)

Fireball creation (Normal Script)

game.Workspace.Fired.OnServerEvent:Connect(function(Player, Debounce)
    local AlreadyTouched = false
    local Character = Player.Character or Player.CharacterAdded:wait()
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://846744780"
    animation = Character.Humanoid:LoadAnimation(animation)
    animation:Play() ----- Active animation
    wait(0.5)
    local Fireball = Instance.new("Part")
    local Fire = Instance.new("ParticleEmitter",Fireball)
    Fireball.Name = "Fireball"
    Fireball.Shape = Enum.PartType.Ball
    Fireball.Size = Vector3.new(2,2,2)
    Fireball.Material = Enum.Material.Neon
    Fireball.BrickColor = BrickColor.new("Deep orange")
    Fireball.CanCollide = false
    Fire.LightEmission = NumberRange.new(0.35)
    Fire.LightInfluence = NumberRange.new(0)
    Fire.Texture = "rbxassetid://405886187"
    Fire.Lifetime = NumberRange.new(0.5)
    Fire.Rate = 20
    Fire.Speed = NumberRange.new(3)
    Fire.SpreadAngle = Vector2.new(15.15)
    Fireball.Parent = Character
    Fireball.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-3)
    local BV = Instance.new("BodyVelocity")
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*100
    BV.Parent = Fireball

    Fireball.Touched:Connect(function(Hit)
        local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

        if Humanoid == nil then return end

        if AlreadyTouched == false then
            AlreadyTouched = true
            local debris = game:GetService("Debris")
                if Humanoid then 
                    local creatorTag = Instance.new("ObjectValue")
                    creatorTag.Value = Player
                    creatorTag.Name = "creator"
                    creatorTag.Parent = Humanoid
                    debris:AddItem(creatorTag, 1)
                end;
            if Humanoid.Parent == Character then
                Humanoid.Health = Humanoid.Health - 0
            else
                Humanoid.Health = Humanoid.Health - Humanoid.MaxHealth/2
                Fireball:Destroy()
            end
        end
    end)
    wait(3)
    Fireball:Destroy()
end)

And finally make a RemoteEvent in Workspace named "Fired"

1
And press F to fire DrTrayaurusBlox -52 — 5y
1
You didn't answer his question, you just added in your own fireball script. Completely not the point. DinozCreates 1070 — 5y
0
But it is relevant to the topic of firing Fireballs DrTrayaurusBlox -52 — 5y
0
Some people dont want to be spoon fed code, they want to learn how things work and why what they're attempting isn't working so that they dont make the same mistake in the future. Helping in this way takes away that opportunity. DinozCreates 1070 — 5y
View all comments (12 more)
0
But I'm trying to help and you're just focusing on me DrTrayaurusBlox -52 — 5y
0
Im trying to help you do a better job of helping. You've been here for less than a day and have -21 reputation. DinozCreates 1070 — 5y
0
So do you want me to delete this post DrTrayaurusBlox -52 — 5y
0
^ Griffi0n 315 — 5y
0
also the code you wrote is worse than his Griffi0n 315 — 5y
1
"Ok, here's a script, and I don't answer the initial question at all. c:" TheeDeathCaster 2368 — 5y
0
he's suspended User#19524 175 — 5y
0
lol rip User#23365 30 — 5y
0
suspended on his first day on scripting helpers User#23365 30 — 5y
0
^ Lmao that ended with a bang Mirzadaswag 110 — 5y
0
and now he has a negative 52 reputation for this. I'm dying of laughter Mirzadaswag 110 — 5y
0
Well, I can't accept your answer because you gave me the completely different script. But thank you for qualitative answer. That must have took you long to write this. Neon_N 104 — 5y

Answer this question