Hello everyone and fellow developers!
I am having some problems with the animations not working for my move set (WIP - Not completed nor final). Here is a video showing it:
Now ofc you can see that first off my animation for the chain holding don’t work at all. It is supposed to be posing. Here are the scripts:
SERVERMODULE:
--//Services
local SS = game:GetService("ServerStorage")
local TS = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
--//Assets
local ServicesSS = SS:WaitForChild("Services")
local ControllerAssets = ServicesSS.Assets.AbilityService["Controller"]
local ContollerModels = ControllerAssets.Models
local ContollerAnimations = ControllerAssets.Animations
local ControllerVFX = ControllerAssets.VFX
local RPF_Animations = ContollerAnimations["Ray Pierce Formation"]
local RPF_Models = ContollerModels["Ray Pierce Formation"]
local RPF_VFX = ControllerVFX["Ray Pierce Formation"]
local RoomExecutionWS = workspace:WaitForChild("Map").Services.AbilityService["Controller"]
--//Remotes
local RPF_Remotes = RS:WaitForChild("Services").Remotes.AbilityService.Controller["Ray Pierce Formation"]
--//Modules
local ControllerSharedModule = require(RS:WaitForChild("Services").Shared.AbilityService.Controller.ControllerShared)
local RPF_Settings = ControllerSharedModule.AbilitySet["Ray Pierce Formation"].Settings
local RPF_TweenInfos = ControllerSharedModule.AbilitySet["Ray Pierce Formation"].TweenInfos
--//Module Functions
local Functions = {}
local function EnableAllParticles(Parent, Value)
for i, v in pairs(Parent:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = Value
end
end
end
local function EnableAllTrails(Parent, Value)
for i, v in pairs(Parent:GetDescendants()) do
if v:IsA("Trail") then
v.Enabled = Value
end
end
end
local function EnableAllBeams(Parent, Value)
for i, v in pairs(Parent:GetDescendants()) do
if v:IsA("Beam") then
v.Enabled = Value
end
end
end
local function TransportVFX(Folder, Parent)
for i, v in pairs(Folder:GetChildren()) do
if v:IsA("ParticleEmitter") then
local Clone = v:Clone()
Clone.Parent = Parent
end
end
end
--EXECUTION MAIN
function Functions:PreExecution(Player, Params)
local Character = Player.Character
print(Character)
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local MouseRay = Params.MouseRay
if not MouseRay then return end
MouseRay = MouseRay.Unit
local RCParams = RaycastParams.new()
RCParams.FilterDescendantsInstances = {Character}
RCParams.FilterType = Enum.RaycastFilterType.Exclude
local Result = workspace:Raycast(MouseRay.Origin, MouseRay.Direction*100000, RCParams)
print(Result)
if Result == nil then
RPF_Remotes.PostExecution:FireClient(Player, RPF_Settings.Cooldown)
return
end
local TargetCharacter = Result.Instance.Parent
local TargetHumanoid = TargetCharacter:FindFirstChild("Humanoid")
local TargetHumanoidRootPart = TargetCharacter:FindFirstChild("HumanoidRootPart")
print(TargetCharacter, TargetHumanoid, TargetHumanoidRootPart)
if TargetHumanoid == nil and TargetHumanoidRootPart == nil then
RPF_Remotes.PostExecution:FireClient(Player, RPF_Settings.Cooldown)
return
end
RPF_Remotes.PreExecution:FireClient(Player, TargetCharacter)
task.wait(6)
Functions:Execute(Player, {["TargetCharacter"] = TargetCharacter})
end
function Functions:Execute(Player, Params)
local Character = Player.Character
local HumanoidRootPart = Character.HumanoidRootPart
local TargetCharacter = Params.TargetCharacter
local TargetHumanoid = TargetCharacter:FindFirstChild("Humanoid")
local TargetHumanoidRootPart = TargetCharacter:FindFirstChild("HumanoidRootPart")
local RoomModel = ContollerModels.RoomModel:Clone()
local PlrFolder = Instance.new("Folder")
PlrFolder.Name = Player.Name
PlrFolder.Parent = RoomExecutionWS
local Room = RoomModel.Room
local OriginalSize = Room:SetAttribute("RoomSize", Room.Size.X)
Room.Size = Vector3.new(0,0,0)
local SpecialMesh = Room.Mesh
local OriginalScale = SpecialMesh.Scale
SpecialMesh.Scale = Vector3.new(0,0,0)
RoomModel.Parent = PlrFolder
RoomModel:PivotTo(HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0,RPF_Settings.RoomHeightFromGround,0)))
HumanoidRootPart.Anchored = true
TargetHumanoidRootPart.Anchored = true
TargetCharacter:PivotTo(Room.CFrame)
print("Passed")
task.wait(1)
RPF_Remotes.Execution:FireClient(Player, "StartCutscene", {["Room"] = Room})
local TweenRoomSize = TS:Create(Room, RPF_TweenInfos.RoomInfo, {Size = OriginalSize})
local TweenMeshScale = TS:Create(SpecialMesh, RPF_TweenInfos.RoomInfo, {Scale = OriginalScale})
TweenRoomSize:Play()
TweenMeshScale:Play()
TweenMeshScale.Completed:Wait()
--Move Camera
task.wait(1)
RPF_Remotes.Execution:FireClient(Player, "TargetCamera", {["Room"] = Room})
--Target Highlight
local Highlight = RPF_Models.Highlight:Clone()
local OT = Highlight.OutlineTransparency
local FT = Highlight.FillTransparency
local HLColor = Highlight.FillColor
Highlight.Parent = TargetCharacter
Highlight.FillTransparency = 1
Highlight.OutlineTransparency = 1
local HLTween = TS:Create(Highlight, TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.In), {FillTransparency = FT, OutlineTransparency = OT})
HLTween:Play()
HLTween.Completed:Wait()
task.wait(2)
--Chain Setup
local ChainGroup = RPF_Models.ChainGroup:Clone()
ChainGroup.Parent = PlrFolder
EnableAllBeams(ChainGroup, false)
ChainGroup:PivotTo(TargetCharacter.HumanoidRootPart.CFrame)
--Attachments on Rig/Connecting
ChainGroup.LeftHand.Beam.Attachment1 = TargetCharacter:WaitForChild("LeftHand").LeftWristRigAttachment
ChainGroup.RightHand.Beam.Attachment1 = TargetCharacter:WaitForChild("RightHand").RightWristRigAttachment
ChainGroup.LeftFoot.Beam.Attachment1 = TargetCharacter:WaitForChild("LeftFoot").LeftAnkleRigAttachment
ChainGroup.RightFoot.Beam.Attachment1 = TargetCharacter:WaitForChild("RightFoot").RightAnkleRigAttachment
--Adjustment of Chain Attachments
local OriginalAttachmentCFrames = {}
for i, Beam in pairs(ChainGroup:GetDescendants()) do
if Beam:IsA("Beam") then
OriginalAttachmentCFrames[Beam.Parent.Name] = Beam.Attachment0.WorldCFrame
Beam.Attachment0.WorldCFrame = Beam.Attachment1.WorldCFrame
end
end
--Camera shift and Enter Tween for Chains
EnableAllBeams(ChainGroup, true)
for i, Beam in pairs(ChainGroup:GetDescendants()) do
if Beam:IsA("Beam") then
local AttachmentTween = TS:Create(Beam.Attachment0, RPF_TweenInfos.ChainAttachmentInfo, {WorldCFrame = OriginalAttachmentCFrames[Beam.Parent.Name]})
AttachmentTween:Play()
end
end
--Animation Track and Start
local PoseTrack = TargetHumanoid.Animator:LoadAnimation(RPF_Animations["Chained Ray Destruction"])
PoseTrack:Play()
PoseTrack:AdjustSpeed(0.25)
PoseTrack:GetMarkerReachedSignal("Pose"):Wait()
PoseTrack:AdjustSpeed(0)
task.wait(5)
--Start Ray Execution
RPF_Remotes.Execution:FireClient(Player, "StartCameraRotation", {["Room"] = Room})
task.wait(1)
--Room VFX
TransportVFX(RPF_VFX.Room, Room)
EnableAllParticles(Room, true)
--SUBLINE RAYS
local RayHits = 0
for i=1,(RPF_Settings.RayProjectors-1) do
task.spawn(function()
local RayProjector = RPF_Models.RayProjector:Clone()
RayProjector.Parent = PlrFolder
RayProjector.Position = Room.Position
for n=1,RPF_Settings.MaxRaysPerProjector do
--Project Ray
local RandomOrientation = CFrame.Angles(math.rad(math.random(-360, 360)),math.rad(math.random(-360, 360)),math.rad(math.random(-360, 360)))
RayProjector.CFrame = RayProjector.CFrame * RandomOrientation
local TargetCFrame = RayProjector.CFrame + (RayProjector.CFrame.LookVector * Room:GetAttribute("RoomSize")/2)
local TargetTween = TS:Create(RayProjector, RPF_TweenInfos.ProjectorInfo, {CFrame = TargetCFrame})
TargetTween:Play()
TargetTween.Completed:Wait()
--Return Ray
local ReturnTween = TS:Create(RayProjector, RPF_TweenInfos.ProjectorInfo, {Position = Room.Position})
ReturnTween:Play()
ReturnTween.Completed:Wait()
RayHits += 1
RPF_Remotes.RayHitsMeter:FireClient(Player, RayHits, (RPF_Settings.RayProjectors*RPF_Settings.MaxRaysPerProjector))
--Highlight hit tween and target effects
local HLTweenIn = TS:Create(Highlight, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.In), {FillColor = Color3.fromRGB(255, 0, 0)})
HLTweenIn:Play()
HLTweenIn.Completed:Connect(function()
task.wait(0.1)
local HLTweenOut = TS:Create(Highlight, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {FillColor = HLColor})
HLTweenOut:Play()
HLTweenOut.Completed:Wait()
end)
end
end)
end
--MAINLINE RAY
local RayProjector = RPF_Models.RayProjector:Clone()
RayProjector.Parent = PlrFolder
RayProjector.Position = Room.Position
local RandomAnimationNumber = 1
for i=1,RPF_Settings.MaxRaysPerProjector do
--Camera Changing to Target
if i == 60 then
RPF_Remotes.Execution:FireClient(Player, "TargetCamera", {["Room"] = Room})
elseif i == 120 then
RPF_Remotes.Execution:FireClient(Player, "StartCameraRotation", {["Room"] = Room})
elseif i == 180 then
RPF_Remotes.Execution:FireClient(Player, "TargetCamera", {["Room"] = Room})
elseif i == 240 then
RPF_Remotes.Execution:FireClient(Player, "StartCameraRotation", {["Room"] = Room})
end
--Project Ray
local RandomOrientation = CFrame.Angles(math.rad(math.random(-360, 360)),math.rad(math.random(-360, 360)),math.rad(math.random(-360, 360)))
RayProjector.CFrame = RayProjector.CFrame * RandomOrientation
local TargetCFrame = RayProjector.CFrame + (RayProjector.CFrame.LookVector * Room:GetAttribute("RoomSize")/2)
local TargetTween = TS:Create(RayProjector, RPF_TweenInfos.ProjectorInfo, {CFrame = TargetCFrame})
TargetTween:Play()
TargetTween.Completed:Wait()
--Return Ray
local ReturnTween = TS:Create(RayProjector, RPF_TweenInfos.ProjectorInfo, {Position = Room.Position})
ReturnTween:Play()
ReturnTween.Completed:Wait()
RayHits += 1
RPF_Remotes.RayHitsMeter:FireClient(Player, RayHits, (RPF_Settings.RayProjectors*RPF_Settings.MaxRaysPerProjector))
local HLTweenIn = TS:Create(Highlight, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.In), {FillColor = Color3.fromRGB(255, 0, 0)})
HLTweenIn:Play()
HLTweenIn.Completed:Connect(function()
task.wait(0.1)
local HLTweenOut = TS:Create(Highlight, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {FillColor = HLColor})
HLTweenOut:Play()
HLTweenOut.Completed:Wait()
end)
end
--Wrap Up and disable VFX for RAYS
RPF_Remotes.Execution:FireClient(Player, "TargetCamera", {["Room"] = Room})
for i, ray in pairs(PlrFolder:GetChildren()) do
if ray.Name == "RayProjector" then
EnableAllParticles(ray, false)
EnableAllTrails(ray, false)
task.delay(5, function()
ray:Destroy()
end)
end
end
EnableAllParticles(Room, false)
task.wait(2)
--Chain Exit Tweening
for i, Beam in pairs(ChainGroup:GetDescendants()) do
if Beam:IsA("Beam") then
local AttachmentTween = TS:Create(Beam.Attachment0, RPF_TweenInfos.ChainAttachmentInfo, {WorldCFrame = Beam.Attachment1.WorldCFrame})
AttachmentTween:Play()
end
end
task.wait(RPF_TweenInfos.ChainAttachmentInfo.Time)
--Destroy and Continue Animation
ChainGroup:Destroy()
PoseTrack:AdjustSpeed(1)
task.wait(1.5)
--Highlight Tween Out
HLTween = TS:Create(Highlight, TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), {FillTransparency = 1, OutlineTransparency = 1})
HLTween:Play()
HLTween.Completed:Wait()
--Close Room and WRAP!
Functions:RoomContraction(Player)
RPF_Remotes.PostExecution:FireClient(Player, RPF_Settings.Cooldown)
HumanoidRootPart.Anchored = false
end
function Functions:RoomContraction(Player)
local PlrFolder = RoomExecutionWS:FindFirstChild(Player.Name)
if not PlrFolder then return end
local RoomModel = PlrFolder.RoomModel
local Room = RoomModel.Room
local SpecialMesh = Room.Mesh
local TweenRoomSize = TS:Create(Room, RPF_TweenInfos.RoomInfo, {Size = Vector3.zero})
local TweenMeshScale = TS:Create(SpecialMesh, RPF_TweenInfos.RoomInfo, {Scale = Vector3.zero})
TweenRoomSize:Play()
TweenMeshScale:Play()
TweenMeshScale.Completed:Wait()
PlrFolder:Destroy()
end
return Functions
Mainly around these lines:
--Animation Track and Start
local PoseTrack = TargetHumanoid.Animator:LoadAnimation(RPF_Animations["Chained Ray Destruction"])
PoseTrack:Play()
PoseTrack:AdjustSpeed(0.25)
PoseTrack:GetMarkerReachedSignal("Pose"):Wait()
PoseTrack:AdjustSpeed(0)
task.wait(5)
Here is the client module:
--//Services and Player
local RS = game:GetService("ReplicatedStorage")
local RunS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local PS = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local Player = PS.LocalPlayer
--//Remotes
local RPF_Remotes = RS:WaitForChild("Services").Remotes.AbilityService.Controller["Ray Pierce Formation"]
--//Camera
local Camera = workspace.CurrentCamera
local Degrees = 0
--//Modules
local ControllersManager = require(Player:WaitForChild("PlayerScripts").Controllers.ControllersManager)
local CutsceneUIsController = ControllersManager:GetController("CutsceneUIsController")
local ShiftLockController = ControllersManager:GetController("ShiftLockController")
local ActiveUIsController = ControllersManager:GetController("ActiveUIsController")
local ControllerSharedModule = require(RS:WaitForChild("Services").Shared.AbilityService.Controller.ControllerShared)
local RPF_Settings = ControllerSharedModule.AbilitySet["Ray Pierce Formation"].Settings
local RPF_TweenInfos = ControllerSharedModule.AbilitySet["Ray Pierce Formation"].TweenInfos
local OriginalCameraCFrame = nil
--//Gui
local ControllerUIs = script.Parent.Parent.Parent
local ControllerGui = ControllerUIs.Controller
local CooldownFrame = ControllerGui.MFrame["Ray Pierce Formation"].Execute.CooldownFrame
local RPFGui = ControllerUIs["Ray Pierce Formation"]
local MeterDisplay = RPFGui.MeterDisplay
local TargetTimer = RPFGui.TargetTimer
--//Assets
local RPF_Models = RS:WaitForChild("Services").Assets.AbilityService.Models.Controller["Ray Pierce Formation"]
--//Localized Debounce
local Debounce = false
--//Meter
local Connection = nil
--//Functions and Connections
local Functions = {}
function Functions.UpdateRayHitsMeter(RayHits, MaxRays)
local Percentage = RayHits/MaxRays
MeterDisplay.TextColor3 = RPF_Settings.RayHitsMeterStartColor:Lerp(RPF_Settings.RayHitsMeterEndColor, Percentage)
MeterDisplay.Text = "Ray Hits: "..RayHits
if Percentage == 1 then
task.wait(3)
local Tween = TS:Create(MeterDisplay, RPF_TweenInfos.RayHitsMeterOutInfo, {TextTransparency = 1})
Tween:Play()
Tween.Completed:Wait()
MeterDisplay.Visible = false
end
end
function Functions.IdentifyEnemy()
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
--Transition
ActiveUIsController:DisableActiveGuis({RPFGui, CutsceneUIsController.GuiEnum})
local EndCFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0,RPF_Settings.IdentifyCameraYOffset,0), HumanoidRootPart.Position)
local CameraTween = TS:Create(Camera, RPF_TweenInfos.VerticalCameraInfo, {CFrame = EndCFrame})
Camera.CameraType = Enum.CameraType.Scriptable
CameraTween:Play()
CameraTween.Completed:Wait()
ShiftLockController:ShiftLock(false)
print("ShiftLock false")
--Mode Select and Identify
local TimerEnterTween = TS:Create(TargetTimer, RPF_TweenInfos.RayHitsMeterEnterInfo, {TextTransparency = 0})
TimerEnterTween:Play()
TimerEnterTween.Completed:Wait()
task.wait(1)
TargetTimer.Timer.Value = RPF_Settings.IdentifyTargetTime
for i = RPF_Settings.IdentifyTargetTime,1,-1 do
TargetTimer.Timer.Value -= 1
TargetTimer.Text = "Pick Your Target: "..TargetTimer.Timer.Value
task.wait(1)
end
TargetTimer.Text = "Target Returning..."
local TimerExitTween = TS:Create(TargetTimer, RPF_TweenInfos.RayHitsMeterEnterInfo, {TextTransparency = 1})
TimerExitTween:Play()
TimerExitTween.Completed:Wait()
--RayCast
local MousePosition = UIS:GetMouseLocation()
local MouseRay = Camera:ViewportPointToRay(MousePosition.X, MousePosition.Y)
return MouseRay
end
function Functions.PreExecution()
if Debounce == false then
Debounce = true
local MouseRay = Functions.IdentifyEnemy()
RPF_Remotes.PreExecution:FireServer({["MouseRay"] = MouseRay})
CooldownFrame.Visible = true
RPF_Remotes.PreExecution.OnClientEvent:Once(function(TargetCharacter)
local TargetHumanoidRootPart = TargetCharacter:WaitForChild("HumanoidRootPart")
local TargetCFrame = CFrame.new(TargetHumanoidRootPart.Position + Vector3.new(0,10,0), TargetHumanoidRootPart.Position)
local CameraTween = TS:Create(Camera, RPF_TweenInfos.VerticalCameraInfo, {CFrame = TargetCFrame})
local Highlight = RPF_Models.Highlight:Clone()
local OT = Highlight.OutlineTransparency
local FT = Highlight.FillTransparency
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = 1
Highlight.Parent = TargetCharacter
local HighlightTween = TS:Create(Highlight, RPF_TweenInfos.VerticalCameraInfo, {OutlineTransparency = OT, FillTransparency = FT})
CameraTween:Play()
HighlightTween:Play()
CameraTween.Completed:Wait()
task.wait(1)
end)
end
end
function Functions.Execution(Status, Params)
local Room = Params.Room
Player:RequestStreamAroundAsync(Room.Position)
local Center = Room.Position
local Radius = (Room:GetAttribute("RoomSize")/2)-20
local RoomModel = Room.Parent
local Connection
if Status == "StartCutscene" then
Camera.CameraType = Enum.CameraType.Scriptable
OriginalCameraCFrame = Camera.CFrame
CutsceneUIsController.StartLoadingTransition()
ActiveUIsController:DisableActiveGuis({RPFGui, CutsceneUIsController.GuiEnum})
local NewCFrame = CFrame.Angles(0,math.rad(Degrees),0) * CFrame.new(0,0,Radius) + Center
local Tween = TS:Create(Camera, RPF_TweenInfos.CameraEnterInfo, {CFrame = NewCFrame})
Tween:Play()
Tween.Completed:Wait()
CutsceneUIsController.EndLoadingTransition()
CutsceneUIsController.StartCutsceneUI()
task.wait(3)
MeterDisplay.Visible = true
MeterDisplay.TextColor3 = RPF_Settings.RayHitsMeterStartColor
MeterDisplay.Text = "Ray Hits: 0"
TS:Create(MeterDisplay, RPF_TweenInfos.RayHitsMeterEnterInfo, {TextTransparency = 0}):Play()
elseif Status == "StartCameraRotation" then
Connection = RunS.RenderStepped:Connect(function(Delta)
Degrees += Delta*RPF_Settings.CameraDegIncrement
end)
Camera.CameraType = Enum.CameraType.Scriptable
local function UpdateCamera(timeSinceLastFrame)
Degrees += timeSinceLastFrame * RPF_Settings.CameraDegIncrement
Camera.CFrame = CFrame.Angles(0, Degrees, 0) * CFrame.new(0, 0, Radius) + Center
end
local Tween = TS:Create(Camera, RPF_TweenInfos.CameraEnterInfo, {CFrame = CFrame.Angles(0, Degrees, 0) * CFrame.new(0, 0, Radius) + Center})
Tween:Play()
Tween.Completed:Wait()
RunS:BindToRenderStep("CameraRotation", Enum.RenderPriority.Camera.Value + 1, UpdateCamera)
elseif Status == "TargetCamera" then
local TargetCamera = RoomModel.TargetCamera
RunS:UnbindFromRenderStep("CameraRotation")
TargetCamera.CFrame = CFrame.new(TargetCamera.Position, Room.Position)
TS:Create(Camera, RPF_TweenInfos.CameraEnterInfo, {CFrame = TargetCamera.CFrame}):Play()
elseif Status == "EndCameraRotation" then
RunS:UnbindFromRenderStep("CameraRotation")
end
end
function Functions.PostExecution(Cooldown)
CutsceneUIsController.EndCutsceneUI()
local ReturnTween = TS:Create(Camera, RPF_TweenInfos.CameraReturnInfo, {CFrame = OriginalCameraCFrame})
ReturnTween:Play()
ReturnTween.Completed:Wait()
ActiveUIsController.EnableInactiveGuis()
ShiftLockController:ShiftLock(true)
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Player.Character.Humanoid
--Cooldown
CooldownFrame.Size = UDim2.new(1,0,1,0)
local Tween = TS:Create(CooldownFrame, RPF_TweenInfos.CooldownFrameInfo, {Size = UDim2.fromScale(0,1)})
Tween:Play()
Tween.Completed:Wait()
Debounce = false
end
return Functions
Now if you can identify the animation problem that would be really helpful . Clearly, the animation is getting passed by the interpreter, as seen with this print statement:
I would also like a better method of making these “pose” animations and how to pause them on the last frame.
Now for the other problem:
This is some weird glitch: External Media
Like you see what happens lol after the camera returns. Here is the shiftlockcontroller if that does help:
--//Services:
local UIS = game:GetService("UserInputService")
local RunS = game:GetService("RunService")
--//Variables:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") -- The HumanoidRootPart
local Mouse = Player:GetMouse()
--//Module Functions
local module = {}
function module:Start()
Mouse.Icon = "rbxassetid://14691803466"
end
function module:ShiftLock(active) --Toggle shift.lock function
print("Shiftlock Toggled: ",active)
if active then
Humanoid.CameraOffset = Vector3.new(0,0,0) -- I assume this is about the right camera offset.
Humanoid.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
RunS:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
end)
else
Humanoid.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
RunS:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
UIS.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
Humanoid.AutoRotate = true --Let the humanoid handle the camera rotations again.
end
end
return module
If anything helps, I appreciate it . If you got any tips on how to organize and structure this better by any chance, also share that! I’m pretty new and just diving into making moves and all that good stuff!
Thanks!