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

Changing the message of a button? (Using GUIs)

I am trying to add text to this GUI button that by clicking on it, it will go from "Spawn Brick" to "Spawning Brick in " .. (some number) .. " seconds". After the time is up, the part will spawn and the GUI text will go back to "Spawn Brick". However, I am not sure how to do this. The script is inside a localscript. Here's my script below:

local spawn = script.Parent -- the spawn variable is the button
local workspace = game:GetService("Workspace")


spawn.MouseButton1Down:connect(function()
local part = Instance.new("Part", workspace)
part.Name = "Test"
part.Anchored = true
part.Position = Vector3.new(5,6,5)
end
end)

1 answer

First of all, it should be in a normal Script in Workspace.

local spawn = script.Parent -- the spawn variable is the button
local workspace = game:GetService("Workspace")

spawn.MouseButton1Down:connect(function()
		local part = Instance.new("Part", workspace)
		part.Name = "Test"
		part.Anchored = true
		part.Position = Vector3.new(5,6,5)
	end --this end doesn't need to be here...?
end)

^That is totally wrong, here:

Put this in a MouseDetector in a Brick.

script.Parent.MouseClick:connect(function(m)
	local msg = Instance.new("Message",workspace)
	msg.Text = "The brick will be spawned in 3 seconds"
	wait(3)
	msg:Destroy()
	local part = Instance.new("Part", workspace)
	part.Name = "test"
	part.Anchored = true
	part.Position = Vector3.new(5,6,5)
end)

1 comment

0

This isn't what I meant. Maybe I have confused others so I will edit my post a bit, sorry for the confusion.

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