Basically i'm trying to make brick that when clicked when clicked, moves a certain model from the serverstorage into the workspace, waits for a little bit, then enables a certain script and then when the block is clicked again it does the reverse moves said model from the workspace back into the serverstorage from the worskpace, waits for a little bit then disables said script. Thanks to viral moose and Scriptree i've learnt how to do these specific functions seperately but I seem to be having alot of trouble joining them together under one script :c
Here are the two scripts (note:They need to both function under one clickdetector brick for what I'm trying to create out of this. I know one's for a gui button and another is for a clickdetector brick
local script1 = workspace.script1 -- Put location of your script you want to enable/disable
function onButtonClicked()
script1.Disabled = false
end
script.Parent.MouseButton1Down:connect(onButtonClicked)
^credit to viralmoose for providing and
local serverstorage = game:GetService("ServerStorage") -- serverstorage is the service to store whatever you want in, Lighting was used before ServerStorage was made
local model = serverstorage:WaitForChild("cheese") -- replace "cheese" with the name of the model under serverstorage
local brick = script.Parent -- variable for the parent of the script, which is what the clickdetector is going to be under
local detector = Instance.new("ClickDetector", brick) -- creating a clickdetector, which is used to be able to click a specific part, and parenting it to the script's parent.
local isinwork = false -- creating debounce for later usage
--[[You have to already have the model positioned as you want it to be shown as, in serverstorage, when it's parented to workspace it will be shown in the position you had it at when u stored the model in serverstorage]]--
function moveModel() -- function that will be called when someone clicks the part
if not isinwork then -- checking if the debounce is false, if it is then it will parent it to workspace
model.Parent = game.Workspace
isinwork = true -- here it is setting the debounce to true so when it's clicked again it is parented to serverstorage
else -- if the debounce is true then it will parent it to serverstorage
model.Parent = serverstorage
isinwork = false -- here it is setting the debounce to false so when it's clicked again it is parented to workspace
end
end
detector.MouseClick:connect(moveModel) -- calling the function when the brick has been clicked
^credit to Scriptree for providing.
I'm not very experienced at all in making scripts from scratch on ROBLOX, I only know some of the basic terminology (but even then, I don't know which terminology are really deemed as "basic" so you can see my struggle here.)
Help would be very much appreciated and I'll be sure to credit you properly if you can help me find a working solution. :D

10 comments
This seems like it should work but the click detector on the brick isn't showing up :(
Update- it says there's an error on line 28 saying ')' expected (to close '(' at line 15) near ''
O, sorry, forgot to put an end to close the if statement fixing right now!
Yeah, that stopped the error but the click detector on the brick still isn't showing up (le cri) I've inputted the model and script names, do I also need to input the name of the brick that I want the click detector to go in somewhere?
and this script needs to be in the brick I want to be clickable for this function, right?
O, you just need to define brick
Ayyy, works now, is there a way to make it so when the model goes back to the serverstorage, the script becomes disabled again?
yea just use an if statement, like if game.Workspace.model then --disable it
Okay, whereabouts would I put this if statement? :)
probably anywhere in the function