I’ve been reordering my code to implement this. It’s slightly better(when you place again its smooth). However, none of the binds work in the second time and I’ve been messing with it to get the binds to work. So far, here’s the current code
onSwitch(nil, Enum.UserInputState.Begin, nil)
game:GetService("ContextActionService"):BindAction("switch", onSwitch, false, Enum.KeyCode.E)
game:GetService("ContextActionService"):BindAction("rotate", onRotate, false, Enum.KeyCode.R)
game:GetService("ContextActionService"):BindAction("place", onPlace, false, Enum.UserInputType.MouseButton1)
game:GetService("ContextActionService"):BindAction("clear", onClear, false, Enum.KeyCode.C)
game:GetService("ContextActionService"):BindAction("save", onSave, false, Enum.KeyCode.F)
player.playerData.Editing:GetPropertyChangedSignal("Value"):Connect(function()
if player.playerData.Editing.Value == true then
if model then
if model.Parent == nil then
model.Parent = placement.CanvasObjects
end
end
elseif player.playerData.Editing.Value == false then
game:GetService("ContextActionService"):UnbindAction("switch", onSwitch, false, Enum.KeyCode.E)
game:GetService("ContextActionService"):UnbindAction("rotate", onRotate, false, Enum.KeyCode.R)
game:GetService("ContextActionService"):UnbindAction("place", onPlace, false, Enum.UserInputType.MouseButton1)
game:GetService("ContextActionService"):UnbindAction("clear", onClear, false, Enum.KeyCode.C)
game:GetService("ContextActionService"):UnbindAction("save", onSave, false, Enum.KeyCode.F)
end
end)
game:GetService("RunService").RenderStepped:Connect(function(dt)
local cf = placement:CalcPlacementCFrame(model, mouse.Hit.p, rotation)
model:SetPrimaryPartCFrame(cf)
end)