Ad
Log in to vote
0

Help with a Mouse / Camera Turn Script. It instead Teleports a player?

Asked by
incapaz 517
7 days ago

I'm trying to do those Jailbreak / MeepCity / Robloxian Highschool scripts where UpperTorso and Head turn to mouse / camera direction facing, but it doesn't work. Btw it's an R15 only game, so no errors there. Thanks.

-- Local Script Inside Starter character scripts

local char = script.Parent
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local upTorso = char.UpperTorso
local head = char.Head
local camera = game.Workspace.CurrentCamera

mouse.Move:Connect(function()
    while wait() do
        upTorso.CFrame = camera.CFrame
        head.CFrame = camera.CFrame
        upTorso.CFrame = mouse.Hit
        head.CFrame = mouse.Hit
    end
end)
0
Does mouse.hit even return a CoordinateFrame value? Fifkee 70 — 7d
0
yes incapaz 517 — 7d
0
Does it says any errors or just doesn`t work? HeyItzDanniee 23 — 7d
0
It just teleports player to mouses Hit incapaz 517 — 6d

1 answer

Log in to vote
0
Answered by 5 days ago

Hello incapaz,

I think the player is teleporting because you are assigning the value of the camera's CFrame to the player's body parts' CFrame. I am not sure if this works, but this might work:

local char = script.Parent
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local upTorso = char.UpperTorso
local head = char.Head
local camera = game.Workspace.CurrentCamera

mouse.Move:Connect(function()
    while wait() do
        camera.CFrame = upTorso.CFrame -- Assigning the current Torso CFrame instead of the other way around
        camera.CFrame = head.CFrame
        upTorso.CFrame = mouse.Hit
        head.CFrame = mouse.Hit
    end
end)

I hope this resolves your issue!

Regards, DefaultAxis

Ad

Answer this question



Ad