I have a problem where for some reason my if statement that controls an effect fires twice. The effect goes from client → server → client (effects are handled on client). However it seems like not any single events are firing twice, but only this seemingly random if line. For context, it also shares the same function as another effect where it uses another color, but that color doesn’t fire twice. Here’s the footage
Here’s the code for it
game.ReplicatedStorage.Events.styleswitch.OnClientEvent:Connect(function(plr)
local TweenStyle = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local char = plr.Character or plr.CharacterAdded:Wait()
local styleswitchnoise = game.ReplicatedStorage.Sounds.styleswitch:Clone()
styleswitchnoise.Parent = plr.Character
styleswitchnoise:Destroy()
local Color = plr.Stats.Color
if Color.Value == "Pink" then
print("Pink!")
if plr.Stats.HeatMode.Value == true then
Deleteheat(char)
Pinkheatenable(char)
end
local StyleSwitch = game.ReplicatedStorage.Particles.Pink.Heat.styleswitch:Clone()
local SwapHighlight = game.ReplicatedStorage.Highlight.Pink.StyleSwap:Clone()
local tweeneffects = coroutine.wrap(function()
local goal = {}
goal.FillTransparency = 1
goal.OutlineTransparency = 1
local Tween = TweenService:Create(SwapHighlight, TweenStyle, goal)
Tween:Play()
Tween.Completed:Wait()
SwapHighlight.Enabled = false
SwapHighlight:Destroy()
end)
tweeneffects()
SwapHighlight.Parent = plr.Character
StyleSwitch.Parent = plr.Character.Torso
StyleSwitch:Emit(500)
wait(3)
StyleSwitch:Destroy()
end
if Color.Value == "Blue" then
print("Blue!!")
if plr.Stats.HeatMode.Value == true then
Deleteheat(char)
Blueheatenable(char)
end
local StyleSwitch = game.ReplicatedStorage.Particles.Blue.Heat.styleswitch:Clone()
local SwapHighlight = game.ReplicatedStorage.Highlight.Blue.StyleSwap:Clone()
SwapHighlight.Parent = char
local tweeneffects = coroutine.wrap(function()
local goal = {}
goal.FillTransparency = 1
goal.OutlineTransparency = 1
local Tween = TweenService:Create(SwapHighlight, TweenStyle, goal)
Tween:Play()
Tween.Completed:Wait()
SwapHighlight.Enabled = false
SwapHighlight:Destroy()
end)
tweeneffects()
StyleSwitch.Parent = plr.Character.Torso
StyleSwitch:Emit(500)
wait(3)
StyleSwitch:Destroy()
end
end)
Hoping someone has a solution!