Hello, I'm using a raycasting gun which only shows the raycast to the user. I'm wondering if I can send the raycast through a remote event in workspace so every player can see it.
Can I make a cloned part from a local script to be sent in the workspace through remote events?
1 answer
Using a LocalScript will only show it on the Client side. If you want a LocalScript to create a part and then send it to the workspace, you will need to use a RemoteEvent.
Create a Script in ServerScriptService and name it whatever you want. Create a RemoteEvent in ReplicatedStorage and name it whatever. Create the LocalScript wherever that is going to call the Event.
In this example:
Script Name: CreatePart
LocalScript Name: LocalCreatePart
Event Name: CreatePartEvent
In LocalScript:
local Event = game:GetService("ReplicatedStorage"):FindFirstChild("CreatePartEvent")
Event:FireServer()
In Server Script:
local Event = game:GetService("ReplicatedStorage"):FindFirstChild("CreatePartEvent")
Event.OnServerEvent:Connect(function(player)
local Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.Name = "Created Part"
print(player.Name.." Created a Part in Workspace")
end)
The above will create a Part in Workspace through a LocalScript with the name of Created Part for all players to see.
Please note: RemoteEvents can be exploited. You should be careful where you place your event. Script Executers can find your event if not hidden well.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Just do it in a localscript
Sorry, I forgot to mention i have filtering enabled
No duh. It was forced
Yes this is possible but think about how practical this is. I would urge you to think about different methods and test which ones work best in gameplay.