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

How do i create Global parts with local scripts?

Asked by 6 years ago

The question is really simple, Is there any way to create a global part with a local script?

This localscript creates a local part:

local part = Instance.new("Part")
part.Parent = workspace

But how do i make it so that the script instead creates a global part?

1
Use RemoteEvents yHasteeD 1819 — 6y
0
Use a ServerScript, why would you use a Local one? HeyItzDanniee 252 — 6y
0
I was creating a building script which uses a GUI to select parts and things like that Vinceberget 1420 — 6y

1 answer

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
6 years ago
Edited 6 years ago

you can use RemoteEvents with arguments for check, example:

-- Server
local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location

event.OnServerEvent:Connect(function(player,arg) -- the first parameter is player, second parameter is argument.
    if arg == "CreatePart" then -- If argument equal to CreatePart
        -- Create part script
        local part = Instance.new("Part")
        part.Parent = workspace
    end
end)

-- Client
local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location

event:FireServer("CreatePart") -- here you dont need to send player, only argument. i send argument "CreatePart"

For your script use this:

Create a RemoteEvent in ReplicatedStorage, now Create a Script(ServerScript/Regular Script) in ServerScriptService and put this code:

local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location

event.OnServerEvent:Connect(function(player,argument)
    if argument == "CreatePart" then
        local part = Instance.new("Part")
        part.Parent = workspace
    end
end)

Now on your LocalScript put this:

local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location

-- Your functions...
event:FireServer("CreatePart")

Hope it helped

Wiki pages

Remote Events/Functions

Ad

Answer this question