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

Why is this script not working?

This script is in a GUI button. When I touch a brick it brings up a GUI and I have a Buy and Cancel button. I have the Cancel button working but not the Buy button. When I click Buy it is suppose to delete/destroy the models (FieldWalls and BuyFieldModel). But it is not!

This is the script that I have: local gui=script.Parent.Parent

function click() game.Workspace.FieldWalls:Destroy() game.Workspace.BuyFieldModel:Destroy() end gui.MouseButton1Click:connect(click)

2 comments

0

Did you use a TextButton for the script? If not PM me on Roblox (TheeDeathCaster) and I'll see what I can do.

0

Not sure what you mean. The script is in a TextButton

1 answer

I'm not sure if this is the problem, but, when connecting a function, don't use variables, use the path to the object.

local gui=script.Parent.Parent

function click()
	game.Workspace.FieldWalls:Destroy() 
	game.Workspace.BuyFieldModel:Destroy() 
end
script.Parent.Parent.MouseButton1Click:connect(click)

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