Once again, Remote Events have come to haunt me. The following is a local script from my egg launcher. Everything works fine except one issue. It launches two eggs at once which spawn on top of each other and get really wonky. I've confirmed that none of the scripts are running multiple times, the event just fires twice or more. I have no idea how I could control this in any way and from what I've seen on the forums, remote events are just horrendous to work with. Any help with why it's firing multiple times would be really appreciated
function fire()
local vCharacter = Tool.Parent;
local dir = HRT.CFrame.lookVector
dir = computeDirection(dir)
local pos = SpawnPart.Position + (SpawnPart.Position - HRT.Position)*2
local EggY = HRT.Orientation.Y
local missilePosition = pos
local missileCFrame = CFrame.new(pos, pos + dir)
local missileOrientation = HRT.Orientation
if not debounce then
debounce = true
print("RanLocalFireFunction")
fireEvent:FireServer(missileCFrame)
debounce = false
end
end
function computeDirection(vec)
local lenSquared = vec.magnitude * vec.magnitude
local invSqrt = 1 / math.sqrt(lenSquared)
return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end
Tool.Enabled = true
function onActivated()
wait(1)
Tool.Enabled = false
IsAttacking = true
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
local targetPos = humanoid.TargetPoint
fire()
local yolkomaticTrack = YolkOMaticModel.AnimationController:LoadAnimation(yolkomaticani)
yolkomaticTrack:Play()
yolkomaticTrack.Looped = false
wait(0.15)
Tool.Enabled = true
end
Here is the script that responds to the firing.
Fired = game.ReplicatedStorage.YolkOMaticFireEvent.OnServerEvent:Connect(function(player, missileCFrame)
Fired:Disconnect()
--Launcher code that has no effect on the Remote Event issue
--
--
--
end)

1 comment
hmm, try adding a wait in that debounce if statment? since :FireServer is the one that activates first thats probarly where the problem is from