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

Why wont my particle emitter work? It won't show up for some reason.

I'm making a dragon game where you press a button to breathe fire and my particle emitter isn't working. Please help!

Here's a sample of my LocalScript in StarterGui

local colorone = Color3.new(255,95,2)
local colortwo = Color3.new(255,255,255)

print("Start of Script")
local fireBreath = Instance.new("ParticleEmitter",game.StarterPlayer.StarterCharacter.Mouth)
fireBreath.Color = ColorSequence.new(colorone,colortwo)
fireBreath.Lifetime = NumberRange.new(10,10)
fireBreath.Rate = 500
fireBreath.Speed = NumberRange.new(60,60)
fireBreath.SpreadAngle = Vector2.new(20,20)
fireBreath.Texture = "rbxassetid://178636145"
fireBreath.EmissionDirection = 5
fireBreath.LockedToPart = true
fireBreath.Enabled = true

game:GetService("UserInputService").InputBegan:connect(function(input,gameprocessed)
	if input.KeyCode==Enum.KeyCode.LeftShift then
		for i = 1,16 do
			wait()
			fireBreath.Enabled = true
		end
	end
end)

game:GetService("UserInputService").InputEnded:connect(function(input,gameprocessed)
	if input.KeyCode==Enum.KeyCode.LeftShift then
		for i = 1,16 do
			fireBreath.Enabled = false
		end
	end
end)

1 answer

✓ Accepted answer

You are trying to place a script inside of StarterCharacter, rather than the player that is running the script.

First of all, I don't recommend using the Instance.new() with a parent as a second argument. It can create unnecessary lag. Instead, parent your instance after you set all of its properties.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")

local fireBreath = Instance.new("ParticleEmitter")
--[[
fireBreath.Color = ...
fireBreath...
etc, set all properties here
]]--
fireBreath.Parent = head

In the code above, I set fireBreath's parent to the local character that is running the script.

Hope this helps! :)

2 comments

0

Thanks for the help! Now I can turn the "fire" on and off but it's locked to a point where I start the game rather than to the model. The controls and camera follow the dragon model but the fire stays connected to point on the ground where I started. Still learning here :)  EDIT: Figured it out! I can change the parent to be a part on the model rather than just character! You rock chomboghai!!

0

Yeah, I just changed my code because I realized the mistake. And thanks! I hope your development goes well!

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