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)
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! :)