Ad
Log in to vote
0

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

Asked by 21 days 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 198 — 21d
0
Yes NykoVania iggyjelly1 6 — 21d

1 answer

Log in to vote
0
Answered by
NykoVania 198 Moderation Voter
21 days 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 6 — 21d
Ad

Answer this question