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

Can I make a cloned part from a local script to be sent in the workspace through remote events?

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.

4 comments

0

Just do it in a localscript

0

Sorry, I forgot to mention i have filtering enabled

1

No duh. It was forced

0

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.

1 answer

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