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

How to make this work?

Trying to spawn a model when I click a TextButton in a screen gui.

model = script.Parent.Parent.Parent.Parent.Lighting["Elephant V2"]
messageText = ""

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
enabled = true

function regenerate()
message.Parent = game.Workspace

wait(1)

model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil

script.Disabled = true
wait(5)
script.Disabled = false
end

script.Parent.MouseClick:connect(regenerate)

3 comments

0

Very broad, try to be more specific.

0

Is this a local script?

1

Any errors?

1 answer

script.Disabled = true

Something tells me that's not quite what you wanted. Did you mean to put a debounce in?

model = script.Parent.Parent.Parent.Parent.Lighting["Elephant V2"]
messageText = ""

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
local enabled = true

function regenerate()
if not enabled then return end; -- If it's not enabled then escape
enabled = false; -- Disable the event temporarily
message.Parent = game.Workspace

wait(1)

model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil

wait(5)
enabled = true; -- Re-enable the event
end

script.Parent.MouseClick:connect(regenerate)

2 comments

0

Doesn't work still.

0

Well how about you say what's actually wrong? "It doesn't work" isn't very helpful.

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