As the title suggests, I have a server script that is trying to use a RemoteEvent to fire to a client. I’m making a round based game and the script works flawlessly the first time through, but when I respawn and try again, it suddenly gives me problems.
I’m not sure why because nothing about the player changes. The script SHOULD work fine (famous last words), I’ve tried using print functions to see what the problem is and it literally just skips over a function.
Here’s my entire Server Side:
local LocalBridge = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("LocalBridge")
local Active = script:WaitForChild("Active")
local Players = game:GetService("Players")
local Player1 = false
local Player2 = false
local Gamemode = false
local Room = false
local timeout = 5
local start = tick()
Active.Changed:Connect(function()
Room = script.Parent
task.wait()
Player1 = Room:WaitForChild("Table"):WaitForChild("Data"):WaitForChild("Player1").Value
Player2 = Room:WaitForChild("Table"):WaitForChild("Data"):WaitForChild("Player2").Value
Gamemode = Room:WaitForChild("Table"):WaitForChild("Data"):WaitForChild("Gamemode").Value
task.wait()----------------------------------------------------------------------------------------------
local LocalScript1 = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("INTROClient"):Clone()
local LocalScript2 = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("INTROClient"):Clone()
local FirstPLR = Players:FindFirstChild(Player1)
local SecondPLR = Players:FindFirstChild(Player2)
if not FirstPLR or not SecondPLR then
warn("Players missing, aborting intro")
return
end
task.wait()
local Char1 = FirstPLR.Character or FirstPLR.CharacterAdded:Wait()
local Char2 = SecondPLR.Character or SecondPLR.CharacterAdded:Wait()
local GameScriptServer = game.ReplicatedStorage:WaitForChild("Gamemodes"):WaitForChild("Server"):WaitForChild(Gamemode):Clone()
local GameScriptClient1 = game.ReplicatedStorage:WaitForChild("Gamemodes"):WaitForChild("Local"):WaitForChild(Gamemode):Clone()
local GameScriptClient2 = game.ReplicatedStorage:WaitForChild("Gamemodes"):WaitForChild("Local"):WaitForChild(Gamemode):Clone()
task.wait(0.1)----------------------------------------------------------------------------------------------
local RoomNameVal = Instance.new("BoolValue")
Char1:WaitForChild("HumanoidRootPart").CFrame = Room:WaitForChild("Player1Intro"):WaitForChild("TeleportPlayer1").CFrame
Char2:WaitForChild("HumanoidRootPart").CFrame = Room:WaitForChild("Player2Intro"):WaitForChild("TeleportPlayer2").CFrame
task.wait()----------------------------------------------------------------------------------------------
RoomNameVal.Name = Room.Name
RoomNameVal.Value = true
task.wait()----------------------------------------------------------------------------------------------
local Val1 = RoomNameVal:Clone()
local Val2 = RoomNameVal:Clone()
task.wait()----------------------------------------------------------------------------------------------
Val1.Parent = Char1
Val2.Parent = Char2
task.wait()----------------------------------------------------------------------------------------------
LocalScript1.Parent = Char1
LocalScript2.Parent = Char2
task.wait(0.1)----------------------------------------------------------------------------------------------
LocalScript1.Enabled = true
LocalScript2.Enabled = true
task.wait(0.1)
while not (FirstPLR and SecondPLR and Room) do
if tick() - start > timeout then
warn("Intro camera failed: missing player or room")
return
end
task.wait()
end
LocalBridge:FireClient(FirstPLR, "MoveToIntroCam1", Room)
LocalBridge:FireClient(SecondPLR, "MoveToIntroCam1", Room)
task.wait(2.1)----------------------------------------------------------------------------------------------
LocalBridge:FireClient(FirstPLR, "PlayIntro", Room)
task.wait(5.5)----------------------------------------------------------------------------------------------
LocalBridge:FireClient(FirstPLR, "MoveToIntroCam2", Room)
LocalBridge:FireClient(SecondPLR, "MoveToIntroCam2", Room)
task.wait(1.8)----------------------------------------------------------------------------------------------
LocalBridge:FireClient(SecondPLR, "PlayIntro", Room)
task.wait(5.5)----------------------------------------------------------------------------------------------
LocalBridge:FireClient(FirstPLR, "SetTheScene", Room)
LocalBridge:FireClient(SecondPLR, "SetTheScene", Room)
task.wait(2)
Char1:WaitForChild("HumanoidRootPart").CFrame = Room:WaitForChild("Table"):WaitForChild("Chair1"):WaitForChild("TeleportChair1").CFrame
Char2:WaitForChild("HumanoidRootPart").CFrame = Room:WaitForChild("Table"):WaitForChild("Chair2"):WaitForChild("TeleportChair2").CFrame
task.wait(1)
GameScriptClient1.Parent = Char1
GameScriptClient2.Parent = Char2
GameScriptServer.Parent = Room
print("Game is ready to start!")
task.wait()
GameScriptServer.Enabled = true
task.wait()
GameScriptServer:WaitForChild("Active").Value = true
GameScriptClient1.Enabled = true
GameScriptClient2.Enabled = true
task.wait(3)
LocalScript1:Destroy()
LocalScript2:Destroy()
script:Destroy()
end)
And here’s my entire Local Side:
local Player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local LocalBridge = game.ReplicatedStorage:WaitForChild("Scripts"):WaitForChild("LocalBridge")
local Camera = game.Workspace.CurrentCamera
local MainAudios = game.Workspace:WaitForChild("PreloadZone")
local Debounce = false
LocalBridge.OnClientEvent:Connect(function(Key, Room, ConfirmValueName)
if Key == "MoveToIntroCam1" and Debounce == false then
local Cam1 = Room:WaitForChild("Player1Intro"):WaitForChild("Camera1")
local TransitionFrame = Player.PlayerGui:WaitForChild("TransitionFrame")
local AudioIn = MainAudios:WaitForChild("IntroAppear"):Clone()
print("Values made!")
task.wait()----------------------------------------------------------------------------------------------
AudioIn.Parent = Player.PlayerGui
local BlackFrame = TransitionFrame:WaitForChild("BlackFrame")
print("Black Frame found and valued!")
for i,anim in ipairs (Player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):GetPlayingAnimationTracks()) do
anim:Stop()
end
print("Animations stopped!")
task.wait()----------------------------------------------------------------------------------------------
BlackFrame.BackgroundTransparency = 0
print("Black frame transaprency set to 0!")
task.wait()----------------------------------------------------------------------------------------------
Camera.CameraType = Enum.CameraType.Scriptable
task.wait()
Camera.CFrame = Cam1.CFrame
print("Camera moved to Cam1!")
task.wait(2.5)----------------------------------------------------------------------------------------------
print("Tweening Black Frame now!")
AudioIn.Playing = true
TweenService:Create(BlackFrame, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {BackgroundTransparency = 1}):Play()
task.wait(6)
AudioIn:Destroy()
else if Key == "MoveToIntroCam2" then
local Cam1 = Room:WaitForChild("Player2Intro"):WaitForChild("Camera2")
local TransitionFrame = Player.PlayerGui:WaitForChild("TransitionFrame")
local AudioIn = MainAudios:WaitForChild("IntroAppear"):Clone()
local AudioOut = MainAudios:WaitForChild("IntroFade"):Clone()
task.wait()
AudioOut.Parent = Player.PlayerGui
task.wait()
AudioOut.Playing = true
TweenService:Create(TransitionFrame.BlackFrame, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {BackgroundTransparency = 0}):Play()
task.wait(1)----------------------------------------------------------------------------------------------
AudioIn.Parent = Player.PlayerGui
for i,anim in ipairs (Player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):GetPlayingAnimationTracks()) do
anim:Stop()
end
task.wait()----------------------------------------------------------------------------------------------
Camera.CameraType = Enum.CameraType.Scriptable
task.wait()
Camera.CFrame = Cam1.CFrame
task.wait(1)----------------------------------------------------------------------------------------------
local Tween = TweenService:Create(TransitionFrame.BlackFrame, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {BackgroundTransparency = 1})
task.wait()
Tween:Play()
AudioIn.Playing = true
task.wait(6)
AudioIn:Destroy()
AudioOut:Destroy()
else if Key == "PlayIntro" then
local Humanoid = Player.Character:WaitForChild("Humanoid")
local IntroAnim = Player:WaitForChild("DataFolder"):WaitForChild("Equipped"):WaitForChild("IntroAnimation").Value
task.wait()
local AnimID = game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Intros"):WaitForChild(IntroAnim)
task.wait()----------------------------------------------------------------------------------------------
local AnimTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(AnimID)
task.wait()----------------------------------------------------------------------------------------------
AnimTrack:Play()
while AnimTrack.TimePosition < 5 do
task.wait()
end
AnimTrack:AdjustSpeed(0)
else if Key == "SetTheScene" then
local Humanoid = Player.Character:WaitForChild("Humanoid")
local TransitionFrame = Player.PlayerGui:FindFirstChild("TransitionFrame")
local SeatedAnim = Player:WaitForChild("DataFolder"):WaitForChild("Equipped"):WaitForChild("SittingAnimations").Value
local AudioOut = MainAudios:WaitForChild("IntroFade"):Clone()
task.wait()
AudioOut.Parent = Player.PlayerGui
task.wait()
local AnimID = game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("AnimPacks"):WaitForChild(SeatedAnim):WaitForChild("Sitting")
TweenService:Create(TransitionFrame.BlackFrame, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {BackgroundTransparency = 0}):Play()
AudioOut.Playing = true
task.wait()
local AnimTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(AnimID)
task.wait(2)
for i,anim in ipairs (Player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):GetPlayingAnimationTracks()) do
anim:Stop()
end
task.wait()
AnimTrack:Play()
task.wait(2)
Camera.CameraType = Enum.CameraType.Follow
local Tween = TweenService:Create(TransitionFrame.BlackFrame, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {BackgroundTransparency = 1})
task.wait()
Tween:Play()
task.wait(2)
AudioOut:Destroy()
end
end
end
end
end)
If anybody spots any issues because I’m too clueless to realize what I did wrong, please let me know. I don’t primarily do scripting, I’ve only gotten into it in the last few months after years of trying and now I’m finally at a level where I can make a mostly functional game, so if I made some rookie mistake, please excuse that.
Regardless, thank you for your time, patience, and I hope you have a great rest of your day.