#Make arms and head face camera when tool is equipped

62 messages · Page 1 of 1 (latest)

scenic hinge
agile stirrup
#

Same goes for the hands

#

You'll also need to send the mouse position from the client

#

I recommend using unreliable remote events for this and minimizing use by only sending when a large enough difference occurred.

#

You can also use buffers to use less bandwidth if it's necessary, it probably isn't

tight shard
#

(Unreliable remote events are faster than regular ones, but they might not transport the information between server/client. But in this case, it won't really matter cuz you have to modify the neck every frame.)

strong python
#

fire:allClient and make a normal function for it firing too many times for just a neck movement make the game laggy

#

or idk you can do it in alot method

#

using reliablefunction or stuff like that

strong python
#

you need to make your own hand

#

with parts

#

then script it

#

like a first person shooter

#

or just make the character humanoid root part look up when you look up is faster than script all the arms

#

or just use a forum script for it

agile stirrup
#

I'm assuming they want purely what they said

strong python
#

okk

agile stirrup
#

You are right with hands being slightly more difficult though

#

as the front face of the arm isn't the palm

#

So it'll need to be rotated

#

You can do this by creating from matrix

#

fromMatrix allows you to construct a cframe using look, up and right vectors

#

So you'd calculate each of them yourself and then switch them around to have the desired side look at the position

#

It sounds difficult but it's only a few lines

#

It should look something like this for the hands

local rightVector = desiredPosition.Unit
local lookVector = rightVector:Cross(Vector3.yAxis)
local upVector = lookVector:Cross(rightVector)
local finalCframe = CFrame.fromMatrix(Vector3.zero, rightVector, upVector, lookVector)

I might've messed something up but it should be mostly correct.
This is also assuming the right face of the arm is the palm, I actually have no idea if it is.

#

It's just to give you an idea on how to

still grove
#

i'm pretty sure you could do this with a local script since client has network ownership

scenic hinge
#

i thought it would just change the cframe with a tween or something

#

im not even that good of a scripter

strong python
scenic hinge
#

as i move the camera the arms and head move too

scenic hinge
#

im not a very good scripter

scenic hinge
#

update:
i got a script but how would i make it smoother?

localscript:

local Player = game.Players.LocalPlayer

local char = Player.Character

local cam = workspace.CurrentCamera

local equipped = false

char.ChildAdded:Connect(function(obj)
    if obj:IsA("Tool") then
        equipped = true
    end
end)

char.ChildRemoved:Connect(function(obj)
    if obj:IsA("Tool") then
        equipped = false
    end
end)

while wait() do
    local head
    local l_arm
    local r_arm
    local lookVector = cam.CFrame.LookVector.Y
    head = CFrame.new(0, 1, 0) * CFrame.Angles(math.clamp(math.asin(lookVector), -0.7, 0.7 ) + 1.55, 3.15, 0)
    if equipped then
        l_arm = CFrame.new(-1, 0.5, 0) * CFrame.Angles(math.clamp(math.asin(lookVector), -0.7, 0.7 ), math.rad(-90), 0)
        r_arm = CFrame.new(1, 0.5, 0) * CFrame.Angles(math.clamp(math.asin(lookVector), -0.7, 0.7 ), math.rad(90), 0)
    end
    game.ReplicatedStorage.Look:FireServer(head, l_arm, r_arm)
end

serverscript:

local tweenService = game:GetService("TweenService")
game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, headCFrame, l_armCf, r_armCf)
    local char = player.Character
    if char and headCFrame then
        local Head = char.Torso:FindFirstChild("Neck", true) :: Motor6D
        local L_Arm = char.Torso:FindFirstChild("Left Shoulder", true) :: Motor6D
        local R_Arm = char.Torso:FindFirstChild("Right Shoulder", true) :: Motor6D

        if Head then
            
            tweenService:Create(Head, TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {C0 = headCFrame}):Play()

            if l_armCf and r_armCf then
                tweenService:Create(L_Arm, TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {C0 = l_armCf}):Play()
                tweenService:Create(R_Arm, TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {C0 = r_armCf}):Play()
            else
                
                tweenService:Create(L_Arm, TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, math.rad(-90), 0)}):Play()
                tweenService:Create(R_Arm, TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.rad(90), 0)}):Play()
            end
        end
    end
end)
#

its a bit choppy

still grove
#

that's because it's running from the server which has latency compared to local

#

do this from a local script because the client is in charge of their own character

scenic hinge
#

dont you need to connect it to the server so others can see it

still grove
#

no, the client had network ownership of their character. that means anything they do to it replicates to other people.

#

network ownership is basically who is doing the thinking, and everyone else just replicates what the owner thinks

#

since the game needs characters to quickly respond to player inputs they are given network ownership

#

typically servers have network ownership of everything else unless explicitly coded otherwise

#

although for physics purposes, unanchored parts have their network ownership set to the nearest player so that if you kick a part its movement replicates to everyone else. anchored parts retain their network ownership to the server always

scenic hinge
agile stirrup
tight shard
still grove
#

you can read more about it online but my guess is it would depend on how you're going about it

#

perhaps if you're manipulating c0s of welds it wouldn't replicate since it's not a physics based thing technically

#

definitely worth looking into

tight shard
#

Ah, I see

marble shadowBOT
#

studio** You are now Level 5! **studio

tight shard
#

thank you

agile stirrup
#

I tried it and transform or C0 doesn't replicate, as expected