Reputation: 1
I'm having a problem with my simple code, im new, heres the code:
local button = game.StarterGui.LoadingGui.MainCanvas.LoadingSequence.Elements.Skip.Button if button.MouseButton1Click then freemouse = false
end
The script should be connected to a button within the interface and it should disable free looking(off by default) when clicked, however as it is currently with this script, you can click anywhere and it will disable free looking, any help is appreciated, thanks.
I've tried to set the MouseButton1Click to a function, which did not resolve the problem.
Upvotes: 0
Views: 556
Reputation: 483
This is how you should use the MouseButton1Click event.
local button = game.Players.LocalPlayer.PlayerGui.LoadingGui.MainCanvas.LoadingSequence.Elements.Skip.Button
-- This function runs when you left click the button.
local function leftClick()
-- do something here
freemouse = false
print("Left mouse click")
end
button.MouseButton1Click:Connect(leftClick) -- connect function
Upvotes: 1