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

Why can't the server side remoteEvent detect objects?

I was creating a building system, and I wanted to make the placement server-sided, so I added a remote event into ReplicatedStorage and had this portion of a LocalScript typed up: (it's specificly this part that isnt working)

function placeItem()
	local place = clone:Clone()
	place.Parent = workspace
	place.PrimaryPart.Transparency = 0
	place.PrimaryPart.CanCollide = true
end

mouse.Button1Down:Connect(function()
	game.ReplicatedStorage.PlaceItem:FireServer(clone)
end)

then, I made a ServerScript in the ServerScriptService and typed up:

game.ReplicatedStorage.PlaceItem.OnServerEvent:Connect(function(player,clone)
	local place = clone:Clone()
	place.Parent = workspace
	place.PrimaryPart.Transparency = 0
	place.PrimaryPart.CanCollide = true
end)

However, it keeps saying that the clone in the serverscript is nil. I clearly defined the object, but it's not detecting it.

What on earth??!! Help please!

3 answers

✓ Accepted answer

You created a clone in the Client's side, which can't be viewed by the server, giving you nil as a result. Try getting the original part from the local script and then cloning it on the server side.

1 comment

0

ty

The reason why is because the client is creating a clone. This makes the cloned object only on the client's side. When sending that cloned object to the server, its gonna end up being nil because it's not replicated on the server. The server would have to use the original object. The server can only work with things that are already on the server. So if the client makes or clones an object that object will only be on the client's side.

I think the reason it didn't work was because you didn't put :FireClient() And you need to connenct the remote event to FireClient()

Also I haven't tested the script. So I might be wrong.

4 comments

0

No no. I meant the server side was not working.

0

ok

0

No. I have a localScript inside the startergui, and a serverscript inside the serverscriptservice. The remote event listener in the serverscriptservice is not picking up the object value of "clone" and just throws and error saying "nil"

0

hmmm

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