What I want to achieve? Make the parent of the local script rotate towards player (on clientside so for each player it rotates towards them)
What is the issue? I can only make the part rotate towards player work if it isnt client-side
What solutions have you tried so far? I tried using CFrame.lookAt, i searched the devforum but nothing worked yet
local Part = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
while task.wait() do
Part.CFrame = CFrame.lookAt(Part.Position, Character:GetPivot().Position)
end
local Part = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local CharRoot = Character:WaitForChild("HumanoidRootPart")
while task.wait() do
Part.CFrame = CFrame.new(Part.Position, CharRoot .Position)
end
First, add a Script into the part. Next, change the RunContext from Legacy to Client. Then, paste this script into the newly created script.
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local part = script.Parent
local player = Players.LocalPlayer
local playerCharacter = player.Character or player.CharacterAdded:Wait()
local runConnection = nil
runConnection = RunService.RenderStepped:Connect(function()
if not playerCharacter then
return runConnection:Disconnect()
end
part.CFrame = CFrame.lookAt(part.Position, playerCharacter:FindFirstChild("HumanoidRootPart").Position)
end)