Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I apply tweenservice to this script?

Asked by
Lyphios 77
4 years ago
Edited 4 years ago

So this script makes the player's head follow the mouse, and to simulate "realism", I put a "wait(0.034)", which is the approximate minimum time a wait can be. But the problem is, it's a bit choppy. I was thinking about reducing the choppiness by using a renderstepped:Wait(), but I have no clue how to do this, and it'd still be pretty choppy. So Here's the script:

local Player = game.Players.LocalPlayer
local Character = Player.CharacterAdded:wait() ; Character = Player.Character
local Torso = Character:WaitForChild'Torso'
local Neck = Torso:WaitForChild("Neck")
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.AutoRotate = false
local HMR = Character:WaitForChild("HumanoidRootPart")

local Mouse = Player:GetMouse()

local NeckC0 = Neck.C0
local NeckC1 = Neck.C1

game:GetService("RunService").RenderStepped:connect(function()
    wait(0.034)
    local cf = workspace.CurrentCamera.CFrame.lookVector.Y

    local Kek = CFrame.Angles(0, 0, math.asin(Mouse.Origin.lookVector.Y))

    Neck.C0 = NeckC0 * CFrame.Angles(math.asin(Mouse.Origin.lookVector.Y), 0, 0):inverse()
    HMR.CFrame = CFrame.new(HMR.Position, Vector3.new(Mouse.Hit.p.x, HMR.Position.Y, Mouse.Hit.p.z))
end)

In line 15, you can see the wait I put. How can I tween this to make it smoother? Sorry if my wording isn't write, I've never actually used tweenservice before.

0
instead of using the closest to the minimum, why dont you just use the minimum? AlexanderYar 788 — 4y
0
That makes an unnoticeable difference Lyphios 77 — 4y
0
You forgot to put Torso in parenthesis/brackets after WaitForChild on line 3. AntiWorldliness 868 — 4y
0
That didn't make a difference Lyphios 77 — 4y

2 answers

Log in to vote
0
Answered by
99Of19 -10
4 years ago

The problem is you're not thinking correctly about the Local Script

Local player = game:GetService("ReplicatedStorage", game.Workspace)

function ChildAdded() = BrickColor.new("Black")
if function is == nil then
local RC0 = CFrame.new(1, .5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local RC1 = CFrame.new(-.5, .5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
if child ~= nil then
function Test1(playeraddedevent)
once player.Humanoid.CFrame = CFrame.Vector.New(("Humanoid")) then he'll
Get("Service"):ChildAddict(function()
local Character = Player.CharacterAdded:wait() ; Character = Player.Character
local Torso = Character:WaitForChild'Torso'
local Neck = Torso:WaitForChild("Neck")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.AutoRotate = false
local HMR = Character:WaitForChild("HumanoidRootPart")
end)

local CFrame = local Mouse = Player:GetMouse("nil")

print("Your welcome")
0
are you trolling Lyphios 77 — 4y
0
I'm only trying to help 99Of19 -10 — 4y
0
it did nothing Lyphios 77 — 4y
0
I reported that guy. He's been doing the same thing on other questions. AntiWorldliness 868 — 4y
0
It's obviously a troll IIFRC, look at his joined date and his Roblox account. Thankfully, he's been suspended. JesseSong 3916 — 2y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local tweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

game:GetService("RunService").RenderStepped:Connect(function()
    local tween = tweenService:Create(player.Character:WaitForChild("HumanoidRootPart", TweenInfo.new(.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = CFrame.new(mouse.Hit.p)})
    tween:Play()
end)

Not sure how to explain it to you, but I think you can figure out what's happening in the script. I had to use someone else's script because I had almost forgotten how to do this, so I guess I'm learning too. I edited the script so hopefully it would be close to what you wanted. If you have questions, I will try to give you the best answer as soon as possible!

Answer this question