I’m trying to make a system where when someone clicks, a boolean changes. With this script, none of the strings are printing, so the input isn’t even being detected and the booleans are not changing.
This is a Localscript inside of StarterCharacterScripts, and the rest of the code works.
I’ve tried using UserInputService instead but that also doesn’t seem to be working inside this script, how would I fix this?
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local movable = true
local UIS = game:GetService("UserInputService")
mouse.Button1Down:Connect(function()
print("Clicked")
if movable == false then
movable = true
print("clickedStart")
elseif movable == true then
movable = false
print("clickedStop")
end
end)
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Movable = true
local function onInputBegan(input, _gameProcessed)
print("Clicked")
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("The left mouse button has been pressed!")
if Movable then
print("clickedStop")
Movable = false
else
Movable = true
print("clickedStart")
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)
Use the UserInputService event OnInputBegan, then you can check if the input type is a mouse click by doing if input.UserInputType == Enum.UserInputType.Button1Down
Maybe try using invisible buttons or something? Or is it something you need for a tool, sword in your inventory and you need to detect when they click to play an animation or something?