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

Help With Button Script?

i wanted the sail of my sailboat to apare on a click of a button something went wrong help me

function Onclicked(mouse)
	script.Parent.mouseButton1click = script.Parent.Parent.Parent.Sail.Transparency = 1
	end
	Onclicked (mouse)

2 answers

You'd have to rewrite the button's script:

function Onclicked(mouse)

	script.Parent.Parent.Parent.Sail.Transparency = 1

end

script.Parent.MouseButton1Click:connect(Onclicked)

Basically, you'd connect the MouseButton1Click's part of the TextButton or ImageButton to a function, in which the function would be called every time the button is pressed.

1 comment

0

Explain the code, it does not benefit the Asker by just pasting code.

So that answer that Reselim did is correct, but he didn't explain lemme explain for you. When you write functions you ALWAYS need to call it or else it won't work! heres an example for a simple button script.

function:

function click()

code:

script.Parent.Visible = true

call the function

script.Parent.MouseButton1Click:connect(click)

as you see I put click in the parenthese. This means that you are talking about this function!

But there is two ways to call it 1.

script.Parent.MouseButton1Click(THE NAME OF FUNCTION)

or

script.Parent.MouseButton1Click:connect(function(click)

Your full script

function Onclicked(mouse)

    script.Parent.Parent.Parent.Sail.Transparency = 1

end

script.Parent.MouseButton1Click:connect(Onclicked)

OR

script.Parent.MouseButton1Click:connect(function(mouse)

    script.Parent.Parent.Parent.Sail.Transparency = 1

end

Both should work any more questions? Ask me!

1 comment

0

Way better than mine.

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