Help on a script please it doesn't work

I want Rotu to follow you and it works but its slow

Heres a video
(won’t load)
You’ll have to play the game → HERE

Code:

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(char)
		local Rotu = game.Workspace:WaitForChild("Rotu")
		Rotu.Parent = game.Workspace
		Rotu.Name = "Following:"..p.Name
		Rotu.Anchored = false
		Rotu.CanCollide = false
		local bp = Instance.new("BodyPosition")
		bp.Parent = Rotu
		
		while wait() do
			bp.Position = char:FindFirstChild("Head").Position + Vector3.new(3,2,0)
		end
	end)
end)

the script is in ServerScriptService

Maybe clone the Rotu?
Add a wait() b4 character added?
Or include prints to see if the script is halting at any point

wait() is very innefective and will usually glitch. I recomend using RunService.Heartbeat:Wait()

-- define the services (you can index tho)
local players = game:GetService("Players")
local runService = game:GetService("RunService")

players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(char)
		local Rotu = workspace:WaitForChild("Rotu")
		Rotu.Parent = workspace
        -- use "workspace" because it's much easier and faster

		Rotu.Name = "Following:"..p.Name
		Rotu.Anchored = false
		Rotu.CanCollide = false
		local bp = Instance.new("BodyPosition")
		bp.Parent = Rotu
		
		runService.Heartbeat:Connect(function() -- use a runservice event instead of a while loop
			bp.Position = char:FindFirstChild("Head").Position + Vector3.new(3,2,0)
		end)
	end)
end)

Usually works fine for me. Idk bout you, just suggesting

it doesn’t work. would changing the mass work?

local players = game:GetService("Players")
local runService = game:GetService("RunService")

players.PlayerAdded:Connect(function(p)
	local char = p.Character or p.CharacterAdded:Wait() -- the character might've loaded

	local Rotu = workspace:WaitForChild("Rotu")
		Rotu.Parent = workspace

		Rotu.Name = "Following:"..p.Name
		Rotu.Anchored = false
		Rotu.CanCollide = false
		local bp = Instance.new("BodyPosition")
		bp.Parent = Rotu
		
		runService.Heartbeat:Connect(function()
			bp.Position = char:FindFirstChild("Head").Position + Vector3.new(3,2,0)
		end)
	end)
end)

nope still doesn’t work. would changing the mass work?

never mind i cant change mass.

add a print function after the “char” variable to see if it actually doesn’t load, it might be loading but not doing anything

local char = p.Character or p.CharacterAdded:Wait()
print('loaded') -- to see if it went past

I did not see the print so it probably didnt load

alright, put it before it

print('loaded')
local char = p.Character or p.CharacterAdded:Wait()

if it still doesn’t work, is this the entire script?

before I test it is there some why I could like union it to the player and make it follow it and not be stuck like a leach

Didnt work no print and instead of slowly descending it just stayed still. so its the entire script ? also the part Rout is a mesh part is that why its not working? image

image

You could use WeldConstraints or Motor6Ds

Try welding it to the player instead if it is jittery/slow. Make sure it is welded to the players head and that it is Massless and CanCollide = false

1 Like

There’s an extra end) at the end of the script, remove it. I forgot to get rid of it when I modified my script

Question: how would I weld it to the player because a player is not really a part

In my post I said that you should weld it to the player’s head. You’ll have to manually readjust the C0 or C1 of the weld to get it in the right position.

I don’t really know any thing about welding like what script or where to put the script and this doesn’t really help.
I’ve noticed the the script is a normal script but has local in it is that purposeful of a mistake. I’m new so don’t know much but try my best. This script might be outdated because i followed a tutorial but changed names to fit my game so that might be it. i hope this explanation will help find the problem.