It's just hovering a block above the player's head but it's really choppy, how do I smooth it out?
local thng = game.ServerStorage.ioo:Clone() game.Players.PlayerAdded:connect(function(plr) thng.Parent = workspace thng.Name = plr.Name.."'s ioo" thng.CanCollide = false local char = workspace:WaitForChild(plr.Name) while wait() do thng.Position = char.Head.Position + Vector3.new(0, 5, 0) end end)
local thng = game.ServerStorage.ioo:Clone() game.Players.PlayerAdded:connect(function(plr) thng.Parent = workspace thng.Name = plr.Name.."'s ioo" thng.CanCollide = false local char = workspace:WaitForChild(plr.Name) while wait() do thng.Position = char.Head.Position + Vector3.new(0, 5, 0) end end)
wait() is about 1/30th of a second.
game:GetService("RunService").RenderStepped:wait()
RenderStepped is about 1/60th of a second, so just add that into it.
local thng = game.ServerStorage.ioo:Clone() game.Players.PlayerAdded:connect(function(plr) thng.Parent = workspace thng.Name = plr.Name.."'s ioo" thng.CanCollide = false local char = workspace:WaitForChild(plr.Name) while game:GetService("RunService").RenderStepped:wait() do thng.Position = char.Head.Position + Vector3.new(0, 5, 0) end end)
Actually, I say the best way to do it is using heartbeat, heartbeat will fire about 40 times per second, ensuring that you get the right CFrame;
first we have to get the runservice;
local rs = get:GetService("RunService").Heartbeat
then, if you wanted you could have it followed by the playeradded function,
local rs = game:GetService("RunService").Heartbeat local thng = game.ServerStorage.ioo:Clone() game.Players.PlayerAdded:connect(function(plr) thng.Parent = workspace thng.Name = plr.Name.."'s ioo" thng.CanCollide = false local char = workspace:WaitForChild(plr.Name) rs:connect(function() thng.Position = char.Head.Position + Vector3.new(0, 5, 0) end) end)
You could use RunService RenderStepped, more specifically :BindToRenderStep(). This is an example of how you can implement this into your script. Or you can just use a weld. You must use :WaitForChild for this so I already changed it for you.
local thng = game.ServerStorage:WaitForChlid('ioo'):Clone() game.RunService:BindToRenderStep("PutAnythingHere", Enum.RenderPriority.Last.Value, function() thng.Parent = workspace thng.Name = plr.Name.."'s ioo" thng.CanCollide = false local char = workspace:WaitForChild(plr.Name) thng.Position = char.Head.Position + Vector3.new(0, 5, 0) end)