I want a function that cleans up old functions to prevent confliction.
- disconnect old functions
- Connect new functions
2a. Have player input happen - When player is done, disconnect functions by re-using the refresh_Edit_Data function
The problem is that connected_Edit1 in this function:
local function refresh_Edit_Data()
if connected_Edit1 then
connected_Edit1:Disconnect()
end
end
Does not update when
connected_Edit1 is assigned a connected function.
Assigning connected_Edit1 below:
connected_Edit1 = input_folder.EditScale.Value.MouseButton1Click:Connect(function()
print(connected_Edit1)
if hit.Parent:WaitForChild("ObjInfo") then
if hit.Parent.ObjInfo:WaitForChild("IsProcedural").Value == true then
game.ReplicatedStorage.BuildingServiceV2.events:WaitForChild("scaleObjectToggle"):FireServer(hit.Parent)
end
end
end)
More Info:
Full code below:
|
|
|
local connected_Edit1
-- This function
-- 1. Disconnects old functions to prevent conflicts
local function refresh_Edit_Data()
if connected_Edit1 then
connected_Edit1:Disconnect()
end
end
local hit = mouse.Target
if hit then
-- checking if valid object
-- NOTE: edit menu buttons below here
if hit.Parent.Parent.Name == "Objects" then
refresh_Edit_Data()
nonInputs_folder:WaitForChild("EditMenu").Value.Enabled = true
connected_Edit1 = input_folder.EditScale.Value.MouseButton1Click:Connect(function()
print(connected_Edit1)
if hit.Parent:WaitForChild("ObjInfo") then
if hit.Parent.ObjInfo:WaitForChild("IsProcedural").Value == true then
game.ReplicatedStorage.BuildingServiceV2.events:WaitForChild("scaleObjectToggle"):FireServer(hit.Parent)
end
end
end)
else
nonInputs_folder:WaitForChild("EditMenu").Value.Enabled = false
refresh_Edit_Data()
end
end