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)
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)