The question is really simple, Is there any way to create a global part with a local script?
This localscript creates a local part:
1 | local part = Instance.new( "Part" ) |
2 | part.Parent = workspace |
But how do i make it so that the script instead creates a global part?
you can use RemoteEvents with arguments for check, example:
01 | -- Server |
02 | local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location |
03 |
04 | event.OnServerEvent:Connect( function (player,arg) -- the first parameter is player, second parameter is argument. |
05 | if arg = = "CreatePart" then -- If argument equal to CreatePart |
06 | -- Create part script |
07 | local part = Instance.new( "Part" ) |
08 | part.Parent = workspace |
09 | end |
10 | end ) |
1 | -- Client |
2 | local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location |
3 |
4 | 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:
1 | local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location |
2 |
3 | event.OnServerEvent:Connect( function (player,argument) |
4 | if argument = = "CreatePart" then |
5 | local part = Instance.new( "Part" ) |
6 | part.Parent = workspace |
7 | end |
8 | end ) |
Now on your LocalScript put this:
1 | local event = game.ReplicatedStorage.RemoteEvent -- RemoteEvent location |
2 |
3 | -- Your functions... |
4 | event:FireServer( "CreatePart" ) |
Hope it helped