How do I make this script work?

Title. I’m trying to make a script inside a button, where I’m trying to make it so that I stop the grid parts I clone disappear.
But the problem is here, is because when I playtest the game, all the scripts in ServerScriptService disappear, which gives me a error in OutPut.

Script:

local button = script.Parent
local Grid = game.ServerScriptService:WaitForChild("Grid")

button.Activated:Connect(function()
		if workspace["Grid Parts"].GridClone.SelectionBox.Archivable == true then
		workspace["Grid Parts"].GridClone.SelectionBox.Archivable = false
		button.Text = "Grid: Disabled"
		button.BackgroundColor = BrickColor.new("Really red")
	else
		workspace["Grid Parts"].GridClone.SelectionBox.Archivable  = true
		button.Text = "Grid: Enabled"
		button.BackgroundColor = BrickColor.new("Sea green")
	end
end)

Screenshots:


The thing is you are on the client and if you want to work with GUIs you’ll need LocalScripts and normal Scripts won’t work

Just noticed, you nees to use RemoteEvents

1 Like

Could you show me how? I haven’t learned how to use RemoteEvents.

Also, all these scripts in ScreenGui are LocalScripts.

I don’t know much about them but you can put them in ReplicatedStorage and then call it by doing

RemoteEvent:FireServer()

And then you can do what you need on the Server, not too sure how it does work as I’m not an expert :sweat_smile:

You would put into the Function the FireServer and then on the Server you would do the check and Clone the things to the Client/move them to Workspace

2 Likes

Oh, as the Player can’t access the Server it’s normal LocaScripts don’t work when trying to get something from the Server

2 Likes

Could you help me with an example?

1 Like

I gave you instructions on my former post, I know how to fire the Remote, just do:

--do tings here
Remote:FireServer(--here to your arguments like player (which is always there) and instance but they’re optional--)
--do other things if you need

But o don’t know the rest sorry :sweat_smile:

3 Likes

1st: put a remote event in the replicated storage, or just somewhere in it
2nd: make a server script in serverscriptservice and make the path to the remote event, and use this example:

local linktoEvent = game:GetService("ReplicatedStorage")

linktoEvent.OnServerEvent:Connect(function(arguments/data you want to transfer from the local script)

end)

hopefully u get the general idea

ah, and another thing; Archivable only makes the thing appear not in-game, just in studio, but like you cant do it in the middle of the running of a server (or as stated in the wiki, “when Archivable is false, the object will not be included when it is a part of a place or model that is saved to a file or published to Roblox.”

2 Likes

You don’t even use Grid in your script, so I don’t see why you cant remove it? In theory, if you do, everything else should work unless you need to do this operation from the server. In that case, use RemoteEvents/RemoteFunctions as @Dede_4242 and @SimLikesCode stated.

2 Likes

ah okay, nvm theres a lot to go over here after a closer look lol

as @acuaro said, you dont really need to use that variable, but not too much of a problem

now second, i dont know exactly what type of instance you want to make invisible is, but i’ll presume its a part. so since Archivable isn’t tied to Transparency or any of that, just if it is published to ROBLOX, you’ll want to use transparency. Zero is visible, and One is invisible. you should get that solved pretty quickly

now i think?? the last problem is that for the button’s backgroundcolor, it wont take a brickcolor, so you’ll want to use rgb for that. it is really simple, and all you need to do is Color3.fromRGB(color). you can get the rgb color from getting a part, choosing it via the brickcolor, and then copying the color instead.

and as i mentioned before, you just need pretty much the same code, just put into a remote event. you use pathtoEvent:FireServer(arguments/data/stuff). just dont include the ui portions, and if u have any questions or need more help just reply i guess

1 Like