Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing the message of a button? (Using GUIs)

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
0
This isn't what I meant. Maybe I have confused others so I will edit my post a bit, sorry for the confusion. Darknesschaos 0 — 9y
Ad

Answer this question