Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Issue with serverscript not running?

Before reading, things you should know:

  • The info i've collected here is from Studio's multiplayer testing server feature only. I'm not sure if this happens if I play it directly from the roblox webstie -- if playing it from there would help solve this issue, let me know.
  • This hasn't happened with any of my other games.

So, in my game, I have a Script in it, plain and simple. It's got some stuff in it obviously, but the only thing that matters is a Print function at the very beginning.

If I test the game straight from Studio, it works as intended, printing the string.

Now let's head over to Studio's server testing. I set it to 1 player and started it up. From the server's point of view, the string prints, but from the client's, it doesn't.

There is absolutely NO situation i've made where the print in the beginning of the script is not supposed to happen, so this must mean that the script isn't running at all. I'm extremely confused here, i've asked other people and didn't understand what they said. This hasn't happened in any of my other games like i've said before, so I have no idea what to do.

-----------------------------------------------------------------EDIT---------------------------------------------------------------

So apparently what's inside the rest of the script does actually matter.

After the prints, the ServerScript holds a few events triggered by RemoteEvents, primarily ones that change properties of Workspace objects.

The case here being that, in Studio Test, I can trigger these RemoteEvents via UserInputService fine, but on Server Test I can't, because the script doesn't run at all.

Once again, I've made FilteringEnabled games before and tested them on server, I've done all the things said here without issue... I just don't know what's causing this and why it hasn't happened in my previous games

-----------------------------------------------------------------EDIT---------------------------------------------------------------

By request, the server script.

-- SETUP: Set up the game when the server starts

print('it works')

jar = require(workspace.jar)
jar.WeldField(workspace)
jar.WeldField(game.ReplicatedStorage.Assets)
comm = game.ReplicatedStorage.Comm
db = game.ReplicatedStorage.Database

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		wait(.5)
		char:MoveTo(workspace.Spawnbox.Base.Position)
	end)
end)

-- IN-GAME STUFF HANDLED BY SERVER: For the few in-game events that are handled on the server instead of the clients

-- Player objects such as object folder. Wouldn't want em to be tampered with eh?

function comm.GSA.OnServerInvoke(player, event)
			if event == 'CreateObjects' then
			
			obj = Instance.new('Folder', player)
		obj.Name = 'Objects'
			cha = Instance.new('StringValue', obj)
		cha.Name = 'vCharacter'
		cha.Value = 'Ace'
				
		for i, v in pairs(game.ReplicatedStorage.Database.Characters[cha.Value]:GetChildren()) do
			local stat = v:Clone()
			v.Parent = obj
		end
		
		-- Find player's character for future reference
		for i, v in pairs(workspace:GetChildren()) do
			if v:IsA'Model' then
				if v:FindFirstChild'Controller' then
					if v.Controller.Value == player.Name then
						playerchar = v
					end
				end
			end
		end
		return obj
	end
end

-- Player character spawning, movement, and positioning

-- Movement

MR = 0
workspace.PlayerMovement.OnServerEvent:connect(function(player, direction)
	print'accepted'
	MR = player.Objects.MoveRate.Value
	local RPV = playerchar.PlayerRootPart.Movement
	if direction == 'Up' then
		print'recieved'
		RPV.Velocity = RPV.Velocity + Vector3.new(MR,0,0)
	elseif direction == 'Down' then
		RPV.Velocity = RPV.Velocity + Vector3.new(-MR,0,0)
	elseif direction == 'Left' then
		RPV.Velocity = RPV.Velocity + Vector3.new(0,0,-MR)
	elseif direction == 'Right' then
		RPV.Velocity = RPV.Velocity + Vector3.new(0,0,MR)
	elseif direction == 'stopUp' then
		RPV.Velocity = RPV.Velocity - Vector3.new(MR,0,0)
	elseif direction == 'stopDown' then
		RPV.Velocity = RPV.Velocity - Vector3.new(-MR,0,0)
	elseif direction == 'stopLeft' then
		RPV.Velocity = RPV.Velocity - Vector3.new(0,0,-MR)
	elseif direction == 'stopRight' then
		RPV.Velocity = RPV.Velocity - Vector3.new(0,0,MR)
	end
end)

6 comments

0

Is FilteringEnabled on?

0

Mhm.

0

Edited.

1

I'm afraid you're going to have to actually show us your code for us to help you.

0

Added script.

0

More info: Turns out the script does actually run on the client, I was an idiot for not realizing that. HOWEVER, the RemoteEvent still does not trigger at all on both server and clients, what's the reason for that?

2 answers

Actually, this isn't an issue at all!

Scripts (as opposed to LocalScripts) don't run on the Client. Your server-sided Script will print on the Server, but if you want to print something to the Client, you have to use a LocalScript!

2 comments

0

Edited.

0

Ah, I misunderstood what you meant.

Server-sided scripts and localscripts are two different things. The server-sided script will print to the server console, and the localscript to the client console. When you play the game all local output will be printed to the output that has the default position to be under your gameplay window. It's the same with the server, but you would have to open the server window.

Please accept if this helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.