Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player = game.Players.LocalPlayer
- TweenS = game:GetService("TweenService")
- uis = game:GetService("UserInputService")
- Char = player.Character or player.CharacterAdded:Wait()
- CharHum = Char:WaitForChild("Humanoid")
- camera = game.Workspace.CurrentCamera
- run = game:GetService("RunService")
- re = game.ReplicatedStorage.Event.PassEvent
- speed = CharHum.WalkSpeed
- db = false
- hum = nil
- Toggle_Db = true
- for i,v in pairs(script.Parent.Parent:GetChildren()) do
- if v:IsA("Humanoid") then
- hum = v
- end
- end
- if speed == 0 then speed = 30 end
- if not hum then return end
- W = script:WaitForChild("W")
- S = script:WaitForChild("S")
- A = script:WaitForChild("A")
- D = script:WaitForChild("D")
- FA = script:WaitForChild("FullA")
- FD = script:WaitForChild("FullD")
- Idle = script:WaitForChild("Idle")
- MasterControl = require(game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
- Directions = {
- Idle = {Vector3.new(0, 0, 0), "Idle"};
- Go = {Vector3.new(0, 0, -1), "Go"};
- Back = {Vector3.new(0, 0, 1), "Back"};
- Right = {Vector3.new(1, 0, 0), "Right"};
- Left = {Vector3.new(-1, 0, 0), "Left"};
- AD_Right = {Vector3.new(1, 0, -1), "AD_Right"};
- AD_Left = {Vector3.new(-1, 0, -1), "AD_Left"};
- AA_Right = {Vector3.new(1, 0, 1), "AA_Right"};
- AA_Left = {Vector3.new(-1, 0, 1), "AA_Left"}
- }
- anim_Table = {
- W = hum:LoadAnimation(W);
- S = hum:LoadAnimation(S);
- A = hum:LoadAnimation(A);
- D = hum:LoadAnimation(D);
- FA = hum:LoadAnimation(FA);
- FD = hum:LoadAnimation(FD);
- Idle = hum:LoadAnimation(Idle);
- }
- info = TweenInfo.new(3.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
- Create_Tween = TweenS:Create(CharHum,info,{WalkSpeed = game.StarterPlayer.CharacterWalkSpeed})
- function stop(name)
- for i,v in pairs(anim_Table) do
- v:Stop()
- end
- Create_Tween:Play()
- end
- anim_Table.Idle:Play()
- if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
- db = false
- else
- db = true
- if (CharHum.MoveDirection).Magnitude > 0 then
- stop()
- anim_Table.W:Play()
- end
- end
- function Movement()
- if not db then
- local move = MasterControl:GetMoveVector()
- if move == Directions.Go[1] then
- stop()
- anim_Table.W:Play()
- elseif move == Directions.Back[1] then
- stop()
- anim_Table.S:Play()
- elseif move == Directions.Right[1] then
- stop()
- anim_Table.FD:Play()
- elseif move == Directions.Left[1] then
- stop()
- anim_Table.FA:Play()
- elseif move == Directions.Idle[1] then
- stop()
- Create_Tween:Cancel()
- CharHum.WalkSpeed = 0
- anim_Table.Idle:Play()
- elseif move == Directions.AA_Left[1] then
- stop()
- anim_Table.A:Play()
- elseif move == Directions.AA_Right[1] then
- stop()
- anim_Table.D:Play()
- elseif move == Directions.AD_Left[1] then
- stop()
- anim_Table.A:Play()
- elseif move == Directions.AD_Right[1] then
- stop()
- anim_Table.D:Play()
- end
- elseif db then
- if (CharHum.MoveDirection).Magnitude == 0 and not Toggle_Db then
- stop()
- Toggle_Db = true
- Create_Tween:Cancel()
- CharHum.WalkSpeed = 0
- anim_Table.Idle:Play()
- end
- end
- end
- function BeganKeys(key,chat)
- if not chat then
- if uis.MouseBehavior ~= Enum.MouseBehavior.LockCenter and db then
- if script:FindFirstChild(key.KeyCode) and Toggle_Db then
- stop()
- Toggle_Db = false
- anim_Table.W:Play()
- end
- else
- db = false
- end
- end
- end
- function LockChanged()
- if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
- db = false
- else
- if uis.MouseBehavior == Enum.MouseBehavior.Default or uis.MouseBehavior == Enum.MouseBehavior.LockCurrentPosition then
- db = true
- if (CharHum.MoveDirection).Magnitude == 0 then
- stop()
- Create_Tween:Cancel()
- CharHum.WalkSpeed = 0
- anim_Table.Idle:Play()
- else
- stop()
- anim_Table.W:Play()
- end
- end
- end
- end
- function FixSpeed(name)
- if name == 'FixSpeed' then
- Create_Tween:Cancel()
- CharHum.WalkSpeed = speed
- end
- end
- --Events
- uis:GetPropertyChangedSignal('MouseBehavior'):Connect(LockChanged)
- uis.InputBegan:Connect(BeganKeys)
- CharHum:GetPropertyChangedSignal("MoveDirection"):Connect(Movement)
- game.ReplicatedStorage.Event.PassEvent.OnClientEvent:Connect(FixSpeed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement