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

Why is it saying I clicked the button?

So I'm trying to make a button for my game to declare war between two countries, and I have a part for each country. So I put a ClickDetector in each part, and here's my script so far:

function activatefalse() script.Parent.ClickDetector.MaxActivationDistance = 0 end if game.StarterGui.Controls.WarButton.MouseButton1Click then script.Parent.ClickDetector.MaxActivationDistance = 999999999999 end

When I run it, the click detector's max distance is already 99999999 even though I didn't click the button yet.

1 comment

0

hey this is not an awnswer but you can click the lua icon and it will make it look like a real script

3 answers

MouseButton1Click requires a function after

game.StarterGui.Controls.WarButton.MouseButton1Click:Connect(function()

1 comment

0

Hmm, the max distance remained at 32 when I clicked the button.

You accidentaly checked for the existence of the event instead of listening for the event. You need to set MouseButton1Click as an event using Connect like this:

function activatefalse() 
  script.Parent.ClickDetector.MaxActivationDistance = 0 
end
game.StarterGui.Controls.WarButton.MouseButton1Click:Connect(function()
    script.Parent.ClickDetector.MaxActivationDistance = 999999999999
end)

3 comments

0

dont put end after the initial function or it wont fire

0

It just remained at 32 though I clicked the button

0

If you put the connection in the activatefalse() function then it would trigger a memory leak because you would keep adding connections without disconnecting them

I tried using the function for the mouse button click but it didn't change.

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