Humanoid:MoveTo() works in studio, but not when joining on a roblox server?

This is my code:

function goTo(hum, torso, position)

	local distance = (position-hum.RootPart.Position).magnitude
	local start = tick()
	while distance > 4 and not cancel do
		distance = (position-hum.RootPart.Position).magnitude
		hum:MoveTo(position)
		hum.MoveToFinished:Wait()
	end
	if cancel then
		position = nil
		return
	end
end

for _, v in pairs(workspace:GetChildren()) do
	if v == touch1 or v == touch2 or v == touch3 then
		v.Touched:Connect(function(hit)
			if hit.Name == "Torso" and not cooldown then
				game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
				local char = hit.Parent
				local goto = v:WaitForChild("GoTo").CFrame.Position

				--Force player to walk to the GoTo
				local player = Players:WaitForChild(char.Name)
				hithum = char:WaitForChild("Humanoid")
				Controls:Disable()
				InputService.MouseBehavior = Enum.MouseBehavior.Default
				InputService.MouseIconEnabled = true
				button = v:WaitForChild("Leave").SurfaceGui.TextButton
				button.Visible = true
				comingback = false
				comeback = v:WaitForChild("ComeBack").CFrame.Position
				goTo(hithum, hit, goto)
			end
		end)
	end
end

Here is a video showing what is happening:

This is probably the same thing I explained here a couple days ago. LocalScript works on studio but not when I play the game - #33 by Scottifly

tbh i didnt wanna post my full code for obvious reasons but if you have an inkling of what could be causing this problem in my code, could you point it out and tell me how i could fix it?

local RunService = game:GetService("RunService")
local InputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local locplayer = Players.LocalPlayer
local character = locplayer.Character or locplayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
local torso = character:WaitForChild("Torso")
local touch1 = workspace:WaitForChild("Text1")
local touch2 = workspace:WaitForChild("Text2")
local touch3 = workspace:WaitForChild("Text3")
local pathfindingService = game.PathfindingService
local Controls = require(locplayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()---GetControls
local GUI = locplayer.PlayerGui
local cursor = GUI:WaitForChild("Cursor").Frame

local comeback
local button
local loc
local comingback = false
local cooldown = false
local cancel = false

local plrnum
local playertext
local hithum


function goTo(hum, torso, position)

	local distance = (position-hum.RootPart.Position).magnitude
	local start = tick()
	while distance > 4 and not cancel do
		distance = (position-hum.RootPart.Position).magnitude
		hum:MoveTo(position)
		hum.MoveToFinished:Wait()
	end
	if cancel then
		position = nil
		return
	end
end

for _, v in pairs(workspace:GetChildren()) do
	if v == touch1 or v == touch2 or v == touch3 then
		v.Touched:Connect(function(hit)
			if hit.Name == "Torso" and not cooldown then
				game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
				local char = hit.Parent
				local goto = v:WaitForChild("GoTo").CFrame.Position

				--Force player to walk to the GoTo
				local player = Players:WaitForChild(char.Name)
				hithum = char:WaitForChild("Humanoid")
				Controls:Disable()
				InputService.MouseBehavior = Enum.MouseBehavior.Default
				InputService.MouseIconEnabled = true
				button = v:WaitForChild("Leave").SurfaceGui.TextButton
				button.Visible = true
				comingback = false
				comeback = v:WaitForChild("ComeBack").CFrame.Position
				goTo(hithum, hit, goto)
			end
		end)
	end
end

RunService.RenderStepped:Connect(function()
	if button ~= nil then
		button.Activated:Connect(function()
			if not comingback then
				comingback = true
				cancel = true
				cooldown = true
				print("Coming Back now")
				wait()
				cancel = false
				goTo(hithum, torso, comeback)
				repeat wait() until humanoid.MoveToFinished
				comingback = false
				button.Visible = false
				Controls:Enable()
				game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
				InputService.MouseBehavior = Enum.MouseBehavior.LockCenter
				InputService.MouseIconEnabled = false
				wait(0.5)
				cooldown = false
			end
		end)
	end
end)

Is this a LocalScript or a Script like I mentioned in the linked post?

LocalScript, sorry i thought that was obvious

Can’t reliably tell if a script is Local or Server from the content of the script itself.
If you read that link it explains why LocalScripts will make things work in studio, but not in game.