Hi,
I want to model follow player smoothly and instantly but its delayed and buggy, its on server script in StarterCharacterScripts using RunService Heartbeat and i want to make it smooth as it was on local script using Renderstepped. Here is script:
local LocalChar = script.Parent.Parent
local HumanoidRootPart = LocalChar:WaitForChild("HumanoidRootPart")
local RS = game:GetService("RunService")
local Aura = script.Parent.aura
RS.Heartbeat:Connect(function()
Aura:MoveTo(HumanoidRootPart.Position + Vector3.new(0, -2.5, 0))
end)
local LocalChar = script.Parent.Parent
local HumanoidRootPart = LocalChar:WaitForChild("HumanoidRootPart")
local RS = game:GetService("RunService")
local Aura = script.Parent.aura
RS.Heartbeat:Connect(function()
Aura.Position = HumanoidRootPart.Position + Vector3.new(0, -2.5, 0))
end
You could change RS.Heartbeat to RS.RenderStepped if you want to
that script dont work, output spits out âInputScript:5: attempt to index nil with âCharacterââ and âInputScript:16: attempt to call a thread valueâ, I tried to fix it but task.spawn is new to me
made some changes and this worked for me in studio
local Aura = game.ReplicatedStorage.Aura --path to the aura
local RS = game:GetService("RunService")
local function AuraFollow(plr)
local char = plr.Character or plr.CharacterAdded:wait()
local clone = Aura:Clone()
clone.Parent = char
RS.RenderStepped:Connect(function()
clone:MoveTo(char.HumanoidRootPart.Position + Vector3.new(0, -2.5, 0))
end)
end
for i, player in pairs(game.Players:GetChildren()) do
coroutine.wrap(AuraFollow)(player)
end
game.Players.PlayerAdded:Connect(function(plr)
coroutine.wrap(AuraFollow)(plr)
end)