Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a brick in the workspace with a TextButton?

Hello, I'm extremely new to scripting and I've been trying to figure out how to make a moving part with a text button. What I've tried so far is obviously putting a TextButton inside a ScreenGUI (yes I put this in StarterGui) and entered a script. This is what I wrote inside the script:

local brick = game.Workspace.MovingPart

moveX = 0
moveY = 0.1
moveZ = 0

function Click()
	brick.CFrame = brick.Cframe - Vector3.new (moveX, moveY, moveZ)
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
	wait (0.1)
	end

script.Parent.MouseButton1Down:connect(Click)

plz send help D:

1 answer

You would need to use a local script along with a Remote Event. Which can be used to tell the server to do something from the client. You can do something like this in the GUI,

Local Script In GUI

local RemoteEvent = game.ServerStorage.RemoteEvents.MakeBrickThingy --Assuming you put it there and name it that--

script.Parent.MouseButton1Down:Connect(RemoteEvent)

Server Script Somewhere in the game (Try ServerStorage, ServerScriptStorage, Workspace, etc)

local brick = game.Workspace.MovingPart

moveX = 0
moveY = 0.1
moveZ = 0

function RemoteEventReceived()
    brick.CFrame = brick.Cframe - Vector3.new (moveX, moveY, moveZ)
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
    brick.CFrame = brick.CFrame - Vector3.new (moveX, moveY, moveZ) 
    wait (0.1)
end

game.ServerStorage.RemoteEvents.MakeBrickThingy.OnServerEvent:Connect(RemoteEventReceived)

This all depends on where you put the event and stuff though, I dont got my studio right now but Im pretty sure you know what I mean. If not I can always help outa in the site or even possibly discord or something. Anyways good luck on the GUI script, may not work as usual but its worth a try!

2 comments

0

Thanks, I will contact you if I need some help!

0

I tried it and it didn't work. There were no errors in the Output tab.

This discussion is preserved as it was. New answers, comments, and votes are closed.