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
game.StarterGui.Controls.WarButton.MouseButton1Click: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:
function activatefalse() script.Parent.ClickDetector.MaxActivationDistance = 0 end game.StarterGui.Controls.WarButton.MouseButton1Click:Connect(function() script.Parent.ClickDetector.MaxActivationDistance = 999999999999 end)
I tried using the function for the mouse button click but it didn't change.