Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can't server Script find a part in Workspace?

Asked by 1 year ago

I have a Tool called C4. When ever it explodes it sends a RemoteEvent called Explosion. Here is what it looks like:

game.ReplicatedStorage.Explosion:Connect(function (Player, HandleName)
    game.Workspace:WaitForChild(HandleName)
end)

Even though a Part named Handle exists in Workspace, it throws me this error:

Handle is not a valid member of Workspace "Workspace"

The only possible issue is that Handle is being created in a LocalScript.

Any Ideas?

0
Is Explosion a Remote Event? NykoVania 231 — 1y
0
Yes NykoVania iggyjelly1 26 — 1y

1 answer

Log in to vote
0
Answered by
NykoVania 231 Moderation Voter
1 year ago

When RemoteEvents are fired from the client, detect them from the server using onServerEvent. Like this:


game.ReplicatedStorage.Explosion.OnServerEvent:Connect(function(Player, HandleName) game.Workspace:WaitForChild(HandleName) end)

Furthermore, instances created from the Client cannot be seen by the Server, so you would have to create the Handle via a ServerScript

0
Thanks! iggyjelly1 26 — 1y
Ad

Answer this question