#i need help with script
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local unitsFolder = ReplicatedStorage:WaitForChild("Units")
local CharacterHandler = {}
function CharacterHandler.SpawnCharacter(name)
local unit = unitsFolder:FindFirstChild(name)
if unit then
local clone = unit:Clone()
clone.HumanoidRootPart.CFrame = workspace:WaitForChild("Start").CFrame
clone.Parent = workspace
local hum = clone:FindFirstChild("Humanoid")
if hum then
local destination = workspace:WaitForChild("End").Position
hum:MoveTo(destination)
hum.MoveToFinished:Connect(function()
if (clone.HumanoidRootPart.Position - destination).Magnitude < 5 then
clone:Destroy()
else
hum:MoveTo(destination)
end
end)
end
end
end
return CharacterHandler