Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

It says Attachment is not a valid member of part?

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?

2 comments

0

The problem's that the script loaded before the attachment was there; to fix this issue, simply use WaitForChild. :)

0

on line 2 add repeat wait() until game.Players.LocalPlayer

2 answers

✓ Accepted answer

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()

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"

16 comments

1

And press F to fire

1

You didn't answer his question, you just added in your own fireball script. Completely not the point.

0

But it is relevant to the topic of firing Fireballs

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.

0

But I'm trying to help and you're just focusing on me

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.

0

So do you want me to delete this post

0

^

0

also the code you wrote is worse than his

1

"Ok, here's a script, and I don't answer the initial question at all. c:"

0

he's suspended

0

lol rip

0

suspended on his first day on scripting helpers

0

^ Lmao that ended with a bang

0

and now he has a negative 52 reputation for this. I'm dying of laughter

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.