Hey Roblox devs. I’m trying to make a muzzle particle emitter show while the player is shooting a gun. I’m using a transparency number sequence to make the particle emitter show and hide. The thing is, I don’t have much experience with coding number sequences.
So, when the player first equips the gun and shoots it, the muzzle shows and hides like it’s supposed to. But, the second time the player shoots the gun it stays transparent.
I have a system that knows wether the player is shooting the gun or not which does work (I know because I’ve done countless prints to make sure my code is working), so I’m thinking I just made a mistake with the number sequence.
If you know anything about number sequences, any help would be appreciated.
Looks like you are entering the numbers correctly, but what about the rest of the script?
It may not be getting set because the script isn’t getting to that section.
You could try printing variables in sections of script to see what their values/booleans are to troubleshoot your code, or post the entire section of the script that deals with the gun firing.
local player = game.Players.LocalPlayer
local tool = script.Parent.Parent.Parent
local MuzzleEvent = player:WaitForChild("gunEvents").Muzzle
local equippedStatus = false
tool.Equipped:Connect(function()
print("equipped")
equippedStatus = true
local Muzzle = player.Character.Blackout.Preview.MuzzleEffect
while equippedStatus == true do
wait(0.025)
Muzzle.Texture = "rbxassetid://421803006"
wait(0.05)
Muzzle.Texture = "rbxassetid://421803091"
wait(0.025)
Muzzle.Texture = "rbxassetid://421803134"
if player.Character.Blackout.ShootingStatus.Value == true then
MuzzleEvent:FireServer()
end
if player.Character.Blackout.ShootingStatus.Value == false then
Muzzle.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(1,1),
}
end
wait()
end
end)
while true do
if equippedStatus == true and not player.Character:FindFirstChild("Blackout") then
equippedStatus = false
end
wait()
end
The “equipped status” variable works, I printed it out, I just didn’t include it in this version of the script. The “shooting status” also works, but I don’t have it included. It’s a seperate script, but I know for a fact that’s not the problem. I could show you that script if you want but it would probably be a waste of time
I was missing a remote event whenever the player stopped shooting the gun, so I was basically making the muzzle transparent through a local script which didn’t work. I recieved both the gunEquip event and the gunNotEquip events in the same server script, like this:
game.Players.PlayerAdded:Connect(function(player) -- this is for getting an instance (folder) that every player in the game starts with
local MuzzleEvent = player:WaitForChild(gunEvents).MuzzleEvent -- "gunEvents" is the instance
local MuzzleStopEvent = player:WaitForChild(gunEvents).MuzzleStopEvent
MuzzleEvent.OnServerEvent:Connect(function(Player)
local Muzzle = Player.Character.Blackout.Preview.MuzzleEffect -- makes the muzzle appear
Muzzle.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,0),
NumberSequenceKeypoint.new(1,0),
}
end)
MuzzleStopEvent.OnServerEvent:Connect(function(Player)
local Muzzle = Player.Character.Blackout.Preview.MuzzleEffect -- makes the muzzle disappear
Muzzle.Transparency = NumberSequence.new{
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(1,1),
}
end)
end)