Horse Spawning System Help

My game has horses and i wanna make a horse calling system like when a key is pressed the horses comes running towards the player its pretty similar to Westbounds horse calling system , i wanna also make it that when the key is pressed the player whistles and the horse comes running
How would i go on making such a system
Heres what explains it better on what i wanna make

Any help is appreciated
Thanks

2 Likes

Well, if the owner can have only one horse in the world, u make an inputbegan with the chosen key, send a signal to the server, get the horse, and as i expect that the horse is a humanoid, u can do:

local horse = objectValue.Value
local character = plr.Character or plr.CharacterAdded:Wait()
local rootpart = character:WaitForChild("HumanoidRootPart")
local direction = rootpart.Position - horse.Main.Position

horse.Humanoid:Move(direction)

But, if he doesnt have a humanoid, you use the system that u placed, but using the direction variable.

Well i dont wanna make it for owners only i wanna make it for all the players they press a key and the horse comes running towards them how would i go on making it could you explain it like a tutorial it would be helpeful

Thanks

So you get the closest horse, see if the horse has a player, and if he has, you continue, you can do that by getting all the horses, and get the closest with magnitude, heres an example:

local closesthorse
local closestdistance = math.huge
local char = plr.Character or plr.CharacterAdded:Wait()

for _, horse in ipairs(workspace.Horses:GetChildren()) do
	local distance = (char.HumanoidRootPart.Position - horse.Main.Position).magnitude
	if distance < closestdistance then
		if not horse:GetAttribute("Occupied") then
			closestdistance = distance
			closesthorse = horse
		end
	end
end

horse:Move(char.HumanoidRootPart.Position - closesthorse.Main.Position)

Thanks i know now what to do
Thanks so much for your help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.