OnServerEvent not doing anything

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.

1 Like

Would you be able to send the full output so that we can see exactly what is being triggered and what isn’t?

1 Like



Wait a second, I forgot to check the studio console.

Does it work in Studio after removing that .Value on the targetCFrame?

I tried that before you sent that message, and yes, that fixed it. Thank you for your help!

Glad everything’s working now! The fact that you weren’t getting anything in the Roblox console is really strange though, did you publish the place after you added print statements to the server script?

No. Why would that affect the console though?

If you don’t publish the place after making any changes, then those changes won’t be replicated to the Roblox client, even though they still work fine in Studio. So what likely ended up happening is that the Roblox client was using an outdated version of your scripts from before you added the print statements to the server script, or possibly before you even had any server script. Because the client sided scripts were published, they were able to run and give you the output in the console, but the server sided scripts likely didn’t exist, and so nothing was being run.

For you and anyone else who comes across this in the future, if you’re not seeing stuff happen in the Roblox client even though it should be, make sure you’ve published it recently.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.