INTRODUCTION
Hi guys! I’ve got a problem with a forsaken roleplay game that i’m creating.
THE PROBLEM
As i’ve stated, i’ve got a problem with the game, and the problem are actually a ton of them. But here is the main one, the main one is that probably because everything i’m doing is on server, sometimes, when 2 players morph at the same time, it basically breaks the morph of the other player and the player that morphed first.
CODES
Morph script inside server script server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReloadCharacterEvent = ReplicatedStorage.LoadCharacterEvent
local SurvivorsFolder = game.ReplicatedStorage.Survivors
local KillersFolder = game.ReplicatedStorage.Killers
ReloadCharacterEvent.OnServerEvent:Connect(function(Player, Button)
local Character = SurvivorsFolder:FindFirstChild(Button.Name) or KillersFolder:FindFirstChild(Button.Name)
local CharacterClone = Character:Clone()
if game.StarterPlayer:FindFirstChild("StarterCharacter") then
game.StarterPlayer.StarterCharacter:Destroy()
end
local NewAnimate = CharacterClone:FindFirstChild("Animate"):Clone()
local NewAbility = ReplicatedStorage.Abilities:FindFirstChild(CharacterClone.Name):Clone()
CharacterClone.Name = "StarterCharacter"
CharacterClone.Parent = game.StarterPlayer
task.wait(0.5)
Player:LoadCharacter()
if Player.Character:FindFirstChild("Animate") then
Player.Character.Animate:Destroy()
end
if Player.PlayerGui:FindFirstChild("Abilities") then
Player.PlayerGui:FindFirstChild("Abilities"):Destroy()
end
task.wait(0.1)
if NewAbility then
NewAbility.Parent = Player.Character
end
if CharacterClone:FindFirstChild("Abilities") then
CharacterClone.Abilities.Parent = Player.PlayerGui
end
NewAnimate.Parent = Player.Character
end)
Client script on a gui:
local StarterPlayer = game:GetService("StarterPlayer")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReloadCharacterEvent = ReplicatedStorage:WaitForChild("LoadCharacterEvent")
local UI = script.Parent
local CharacterTypeFrame = UI.CharacterType
local UIPageLayout = UI.UIPageLayout
local SurvivorsButton = CharacterTypeFrame.Survivors
local KillersButton = CharacterTypeFrame.Killers
local SurvivorsFrame = UI.Survivors
local KillersFrame = UI.Killers
UI.Visible = true
SurvivorsButton.MouseButton1Up:Connect(function()
UIPageLayout:JumpTo(UI.Survivors)
end)
KillersButton.MouseButton1Up:Connect(function()
UIPageLayout:JumpTo(UI.Killers)
end)
for i, v in pairs(SurvivorsFrame:GetChildren()) do
if v:IsA("ImageButton") then
v.MouseButton1Up:Connect(function()
task.wait(0.1)
ReloadCharacterEvent:FireServer(v)
UI.Visible = false
end)
end
end
for i, v in pairs(KillersFrame:GetChildren()) do
if v:IsA("ImageButton") then
v.MouseButton1Up:Connect(function()
task.wait(0.1)
ReloadCharacterEvent:FireServer(v)
UI.Visible = false
end)
end
end
END
How can i solve this?