Hello everyone, so I have a deployable ladder script. The problem is that I cannot rotate it while moving it because the CFrame is getting set to the same as the mouse all the time. I wanted to ask if there is any way of letting it rotate while moving it.
https://gyazo.com/07834920ac940a95385843e60c9bef64
script:
local tool = script.Parent
local previews = workspace.LadderStuff.Previews
local realadders = workspace.LadderStuff.Stages
local one = previews.PStage1
local two = previews.PStage2
local three = previews.PStage3
local four = previews.PStage4
local five = previews.PStage5
local six = previews.PStage6
local seven = previews.PStage7
local eight = previews.PStage8
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local equipped
local value = script.Parent.CurrentPreview
local useri = game:GetService("UserInputService")
local connection
local gui = script.Parent.LadderGui or plr.PlayerGui.LadderGui
------------------------------------------------------------------
local b1 = realadders.Stage1
local b2 = realadders.Stage2
local b3 = realadders.Stage3
local b4 = realadders.Stage4
local b5 = realadders.Stage5
local b6 = realadders.Stage6
local b7 = realadders.Stage7
local b8 = realadders.Stage8
------------------------------------------------------------------
tool.Equipped:Connect(function(mouse)
gui.Parent = plr.PlayerGui
print("Weapon equipped")
one.Transparency = 0.7
value.Value = one
equipped = true
connection = useri.InputChanged:Connect(function(Input, gameProcessed)
if Input.UserInputType == Enum.UserInputType.MouseMovement then
if gameProcessed then return end
if equipped == false then connection:Disconnect() return end
print("Loop")
local pos = (mouse.Hit.Position)
if value.Value == one then
one.CFrame = CFrame.new(pos + Vector3.new(0,6,0))
end
end
end)
end)
tool.Unequipped:Connect(function(mouse)
gui.Parent = plr:WaitForChild("BackPack"):WaitForChild("DeployableLadder")
print("Weapon unequipped")
equipped = false
one.Transparency = 1
end)
useri.InputBegan:Connect(function(input)
print("Input made")
if input.KeyCode == Enum.KeyCode.R then
print("Correct input")
if value.Value ~= nil then
local pre = value.Value
if pre ~= nil then
print("Part rotated")
pre.CFrame = pre.CFrame * CFrame.Angles(0, math.rad(20), 0)
else
print("Value nil")
end
end
end
end)