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.
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.