I’m trying to make a debug command to trigger a server event, but the event doesn’t seem to be firing at all. When I look at the console, I don’t see any errors.
Here is the code for the debug command (this is only a part of the script, located in ServerScriptService
)
if (messageWords[2] == 'rotateTelescope') then
local X = tonumber(messageWords[3])
local Y = tonumber(messageWords[4])
local Z = tonumber(messageWords[5])
ReplicatedStorage.telescopeDebugEvent:FireClient(player, CFrame.Angles(math.rad(X), math.rad(Y), math.rad(Z)))
end
The local script that uses telescopeDebugEvent
(located in StarterPlayerScripts
)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Telescope = ReplicatedStorage.telescope
local Event = ReplicatedStorage.telescopeDebugEvent
Event.OnClientEvent:Connect(function(targetCFrame)
print("Relaying debug command to client so it can tell the server to rotate the telescope.")
Telescope.RotateToTarget:FireServer(targetCFrame)
end)
And here’s the server script that uses the RotateToTarget
event. (located in ServerScriptService
)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Telescope = ReplicatedStorage.telescope
local RotationSpeed = Telescope.RotationSpeed
local Info = TweenInfo.new(20 - RotationSpeed.Value, Enum.EasingStyle.Circular, Enum.EasingDirection.InOut)
Telescope.RotateToTarget.OnServerEvent:Connect(function(player, targetCFrame)
print("Got event to rotate space telescope.")
local TweenGoal = {}
TweenGoal.Value = targetCFrame.Value
local Tween = TweenService:Create(Telescope.CFrame, Info, TweenGoal)
print("Rotating space telescope...")
Tween:Play()
Tween.Completed:Wait()
print("Finished rotating space telescope.")
end)
When I use the command, I can see that the local script receives the event just fine, but the server script doesn’t output or do anything at all. I don’t see any errors in the console either.