I'm trying to connect a function when a variable is true and disconnect when you press x
I keep getting this error:
Attempt to connect failed: Passed value is not a function 23:12:22.419 - Script 'Players.Player.PlayerScripts.Placing', Line 19
--//Predefines
local uis = game:GetService("UserInputService")
--//Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = game.Workspace.CurrentCamera
local Database = game.ReplicatedStorage
local Mouse = Player:GetMouse()
local itemGui = Player.PlayerGui.Guis.Items
local currentlyPlacing = false
--//Item placing
function updatePlacingPosition(position)
print(position)
end
local placing = Mouse.Changed:connect(updatePlacingPosition(Mouse.hit.p))
placing:disconnect()
--//Item placing buttons
for i,v in pairs (itemGui:GetChildren()) do
v.MouseButton1Down:connect(function()
currentlyPlacing = true
placing:connect()
end)
end
--//Item disconnecting button
uis.InputBegan:connect(function(input, typing)
if not typing and input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.X then
placing:disconnect()
end
end
end)
