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)
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)
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.
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!
Way better than mine.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Explain the code, it does not benefit the Asker by just pasting code.