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.
MouseButton1Click requires a function after
1 | game.StarterGui.Controls.WarButton.MouseButton 1 Click:Connect( function () |
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:
1 | function activatefalse() |
2 | script.Parent.ClickDetector.MaxActivationDistance = 0 |
3 | end |
4 | game.StarterGui.Controls.WarButton.MouseButton 1 Click:Connect( function () |
5 | script.Parent.ClickDetector.MaxActivationDistance = 999999999999 |
6 | end ) |
I tried using the function for the mouse button click but it didn't change.