I am creating a fighting game and so to make the different moves I decided to use remote events, so whenever a player presses a key a remote event is fired. Everything works fine whenever one player does it, though if multiple players activate the remote event at the same time it completely breaks and will only work for one, breaking the server script for the second. Here’s an example of script :
–client
mouse.KeyDown:connect(function(key,gameProcessedEvent)
if key:lower() == “z” or key:upper() == “Z” and not gameProcessedEvent then
disabled = script.Parent:WaitForChild(“Disabled”).Value
if not cooldown and not cooldown11 and not disabled then
if not script.Parent:FindFirstChild(“HorseModel”) then
cooldown = true
cooldown11 = true
wait(0.1)
HorseEvent:FireServer("mount")
wait(2)
cooldown = false
wait(4)
cooldown11 = false
else
cooldown11 = true
HorseEvent:FireServer("dismount")
wait(3)
cooldown11 = false
end
end
end
end)
– server
function Horse(player, action)
if action == "mount" then
horse = ReplicatedStorage.Characters.Johnny.HorseModel:Clone()
horse.Parent = player.Character
sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://2761977919"
sound.Parent = player.Character.Head
sound.PlayOnRemove = true
sound:Destroy()
wait(0.5)
player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame*CFrame.new(0,6,0)
player.Character.HumanoidRootPart.Anchored = true
horse.Saddle1.BPart1.CFrame = player.Character.HumanoidRootPart.CFrame*CFrame.new(0,-5,0)
player.Character.HumanoidRootPart.Anchored = false
sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://178645076"
sound.Parent = horse.Saddle
sound.PlayOnRemove = true
sound:Destroy()
horse.Saddle1.BPart1:Destroy()
else
player.Character:WaitForChild("HorseModel").Saddle.Disabled = true
player.Character:WaitForChild("HorseModel"):Destroy()
player.Character.Humanoid.JumpPower = 0
end
end
HorseEvent.OnServerEvent:Connect(Horse)
I thought I knew how remote events worked but apparently not. In this case the error states that “BPart1 is not a valid member of Model” even though this works fine with one player. The error also happens with the other remote events.