How to trigger RemoteEvent in ServerScriptService

I am using a local script and I want to trigger a RemoteEvent that is in a script in ServerScriptService

local ServerScriptService = game:GetService("ServerScriptService")
Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")


UIS.InputBegan:Connect(function(input, gpe)
	if gpe then 
		return
	end
	ServerScriptService.PlaceBlock.PlaceEvent:FireServer(game.Workspace.Ignore:WaitForChild("SelectBox"):FindFirstChildWhichIsA("BasePart"))
	
end)

Running the svript returns the following error:
*PlaceBlock is not a valid member of ServerScriptService “ServerScriptService” *

Localscripts cannot get anything in ServerScriptService or ServerStorage, you have to move it somewhere clients can see, such as ReplicatedStorage and change some code around

3 Likes

But I thought Scripts couldn’t run in ReplicatedStorage?

Put only the RemoteEvent in ReplicatedStorage, keep the script in ServerScriptService and change the reference to the remote event to match the new location

1 Like

Also to add on to what localscripts can and cannot do the local script needs to be a descendant of the player ( in player) and inside the player at some point to run clientside or else it won’t run (it won’t run clientside if it isn’t in a client’s player descendants )

Places within the Player

  • StarterCharacterScripts - will place it within character as it spawns to be exact
  • StarterPlayerScripts - will place it within player as they join
  • StarterGui - will place it within playerGui as they join or spawn
    and many more
1 Like

Ok, that leaves me with another question, I am trying to send a locally generated instance as a value through the RemoteEvent, for the script to clone it, do I have to serialize it?

I believe so as if it’s locally generated, the server doesn’t know about it so it would nil if you send it through. If you’re sending in the instance directly, you probably will have to, otherwise if you’re trying to send a property only, it should be fine to do it regularly

1 Like

Alright, I just hope you can serialize MeshParts / Models.

1 Like

oop and I just realized you
have to serialize things yourself :flushed: :flushed: :flushed:

1 Like

I’ve seen it said a lot but I don’t quite know exactly what it is I’m assuming it will allow you to gather instances and place all properties into table form so you can send them to the server

But you said u want to do this to MeshParts and if I remember correctly the MeshId property in MeshParts is read only

but a simple fix would just be to clone the mesh from serverside

1 Like

Yeah I decided to go for a that solution, i have all the objects in Replicated storage, So im just going to send a reference to the object and the properties needed, But i would still have to serialize the properties to know its classname and value

1 Like