cuz the server get set up first it will then fire the remoteevent before the player sets up his connect.
the player is still loading the game while the remote event gets fired
or any other delay that waits for the player to stop loading
I have added a delay (4 seconds) before the FireAllClients function, but somehow the script prints “nok” right after clicking play. Still didn’t worked, I don’t know what is the problem…
--ReplicatedStorage stuff
local GameFunctionsModule = game:GetService("ReplicatedStorage"):WaitForChild("GameFunctions")
local RemoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")
--Model variables
local Model = workspace:WaitForChild("PlayerCharacter")
local HeadCamera = Model.Head
local SecondCamera = Model.SecondCamera
local ModelAnimator = Model:WaitForChild("MAIN_HUMANOID"):WaitForChild("Animator")
--Animation
local Animation = ModelAnimator:LoadAnimation(script:WaitForChild("Animation"))
--Play animation
Animation:Play()
--Tower smoke turning red; for animation event #1
local RedCK = {
--API: ColorSequenceKeypoint.new(time, color)
ColorSequenceKeypoint.new( 0, Color3.fromRGB(255,0,0)),
ColorSequenceKeypoint.new(.5, Color3.fromRGB(255,0,0)),
ColorSequenceKeypoint.new( 1, Color3.fromRGB(255,0,0))
}
local RedCS = ColorSequence.new(RedCK)
local TowerSmoke = workspace.NotNecessary.Lyoko.InsideActivatedTower.Smoke.ParticleEmitter
Animation:GetMarkerReachedSignal("TurnTowerSmokeRed"):Connect(function(paramString)
TowerSmoke.Color = RedCS
end)
--Functions
wait(4)
RemoteEvent:FireAllClients(SecondCamera)
print("nok")
Local script
--CoreUI elements
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
--Player
local Player = game:GetService("Players").LocalPlayer
--Model
local Model = workspaceF:indFirstChild("PlayerCharacter")
local HeadCamera = Model.Head
local SecondCamera = Model.SecondCamera
--ReplicatedStorage stuff
local GameFunctionsModule = game:GetService("ReplicatedStorage"):WaitForChild("GameFunctions")
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
--Camera
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
--Functions
RemoteEvent.OnClientEvent:Connect(function(part)
print("ok")
game:GetService("RunService").RenderStepped:Connect(function()
Camera.CFrame = part.CFrame
end)
end)