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

(Answered) How Do I Create Instances From A Local Script For The Entire Server To See?

Asked by 5 years ago
Edited 5 years ago

Today I tried to create a local script that creates new instances in the workspace for the entire server but unfortunately I don't understand how to communicate after the filtering enabled update and I wasted somewhere in between an hour and a half to 2 hours trying to figure it out using remote functions and events until I scrapped everything except the local script in one of the starter gui's, Here it is:

script.Parent.MouseButton1Click:Connect(function()
    local MusicFolder = Instance.new("Folder", workspace)
    local SongId = Instance.new("NumberValue", workspace)
    local Username = Instance.new("StringValue", workspace)
    SongId.Value = script.Parent.Parent.TextBox.Text
    Username.Value = script.Parent.Parent.Parent.Parent.Parent.Name
    SongId.Parent = MusicFolder
    Username.Parent = MusicFolder
    SongId.Name = "SongId"
    Username.Name = "Username"
    MusicFolder.Parent = game.Workspace.MusicGenerator
end)

Could someone please show me how to make the folder and values spawn in the workspace for the entire server and not just for the client?

1 answer

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

To bypass filtering enabled, you'll have to use remote events, since the client's changes to the workspace do not replicated. I wasn't sure what the parents of your script were, so excuse the poor variable names in the remote event.

--Local script

local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") --wait for remote

script.Parent.MouseButton1Click:Connect(function()
   remote:FireServer(script.Parent.Parent.Parent.Parent.Parent.Name,script.Parent.Parent.TextBox.Text) --send needed data
end)


--Server script

local RepStorage = game:GetService("ReplicatedStorage")
local remote = Instance.new("RemoteEvent") --create remote
remote.Parent = repStorage

remote.OnServerEvent:Connect(function(player,name,TextboxText)
    local MusicFolder = Instance.new("Folder") --second argument of .new() deprecated
    MusicFolder.Parent = workspace
    local SongId = Instance.new("NumberValue")
    SongId.Parent = workspace
    local Username = Instance.new("StringValue")
    Username.Parent = workspace
    SongId.Value = TextboxText
    Username.Value = name
    SongId.Parent = MusicFolder
    Username.Parent = MusicFolder
    SongId.Name = "SongId"
    Username.Name = "Username"
    MusicFolder.Parent = game.Workspace.MusicGenerator
end)

Resources:

Remote Events

Accept and upvote if this helps!

0
@gioni01 Thank You So Much! (Sorry I Can't Up vote Your Answer, I Just Created My Scripting Helpers Account Today And I Need 25 Reputation) kizi3000 88 — 5y
1
its okay! Gey4Jesus69 2705 — 5y
0
Now That I Have Enough Reputation I Up voted kizi3000 88 — 5y
1
lol thanks Gey4Jesus69 2705 — 5y
Ad

Answer this question