I'm trying to create wall running, and I want the character not to break away from wall during holding a key, if you look to the sides. The idea is that the character's motion vector would coincide with the orientation vector of the wall. Problem is the data types inside Roblox is different and I can't just equate them. (look under comment)
local c = script.Parent local holdingKey = false local uis = game:GetService("UserInputService") local leftAnim = c.Humanoid:LoadAnimation(script:WaitForChild("WallrunLeft")) local rightAnim = c.Humanoid:LoadAnimation(script:WaitForChild("WallrunRight")) uis.InputBegan:Connect(function(inp, p) if not p and inp.KeyCode == Enum.KeyCode.F then holdingKey = true end end) uis.InputEnded:Connect(function(inp) if inp.KeyCode == Enum.KeyCode.F then holdingKey = false end end) game:GetService("RunService").Heartbeat:Connect(function() local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Blacklist; raycastParams.FilterDescendantsInstances = {c}; raycastParams.IgnoreWater = true; local rayL = workspace:Raycast(c.HumanoidRootPart.CFrame.Position, -c.HumanoidRootPart.CFrame.RightVector * 3, raycastParams) local rayR = workspace:Raycast(c.HumanoidRootPart.CFrame.Position, c.HumanoidRootPart.CFrame.RightVector * 3, raycastParams) local ray = rayL or rayR if ray and holdingKey then if ray == rayL then if not leftAnim.IsPlaying then leftAnim:Play() end rightAnim:Stop() else if not rightAnim.IsPlaying then rightAnim:Play() end leftAnim:Stop() end local part = ray.Instance local weld = c.HumanoidRootPart:FindFirstChild("WallrunWeld") or Instance.new("WeldConstraint") weld.Name = "WallrunWeld" weld.Part0 = c.HumanoidRootPart weld.Part1 = part local bp = c.HumanoidRootPart:FindFirstChild("WallrunBodyPosition") or Instance.new("BodyPosition", c.HumanoidRootPart) bp.Name = "WallrunBodyPosition" bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge) -- implementation of running!!!!!!! bp.Position = c.HumanoidRootPart.Position + c.HumanoidRootPart.CFrame.LookVector * (game.Players.LocalPlayer.Character.Humanoid.WalkSpeed*0.5) print(ray.Instance.Orientation) print(c.HumanoidRootPart.CFrame.LookVector) else for i, child in pairs(c.HumanoidRootPart:GetChildren()) do if child.Name == "WallrunWeld" or child.Name == "WallrunBodyPosition" then child:Destroy() end end leftAnim:Stop() rightAnim:Stop() end end)
If I understand correctly, you want to convert rad to deg or deg to rad. Roblox has functions for converting this.
math.deg() -- Put a radian number (lookvector), it returns that number in degrees math.rad() -- Put a degree number (orientation), it returns that number in radians --example local orientationToRadians = Vector3.new(math.rad(X),math.rad(Y),math.rad(Z))
I also think Roblox at one point had CFrame.fromorientation or something like that but don't use it,