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

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

Asked by 5 years ago

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.

0
Just do it in a localscript MaxDev_BE 55 — 5y
0
Sorry, I forgot to mention i have filtering enabled Lamantinel -1 — 5y
1
No duh. It was forced User#19524 175 — 5y
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. User#5423 17 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

Ad

Answer this question