Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is it saying I clicked the button?

Asked by 3 years ago

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.

0
hey this is not an awnswer but you can click the lua icon and it will make it look like a real script LTRNightmare 66 — 3y

3 answers

Log in to vote
0
Answered by
VVoretex 146
3 years ago

MouseButton1Click requires a function after

game.StarterGui.Controls.WarButton.MouseButton1Click:Connect(function()
0
Hmm, the max distance remained at 32 when I clicked the button. I_vNextLevel 2 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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)
0
dont put end after the initial function or it wont fire VVoretex 146 — 3y
0
It just remained at 32 though I clicked the button I_vNextLevel 2 — 3y
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 awesomebanana2018 36 — 3y
Log in to vote
0
Answered by 3 years ago

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

Answer this question