You can write your topic however you want, but you need to answer these questions:
-
I am trying to make a rideable, breedable, pet unicorn that will follow you. For now I am working on the rideable part
-
What is the issue? Include screenshots / videos if possible!
The Unicorn does not move no matter what I try. The closest I’ve gotten is the unicorn gliding like its on ice but not turning like a normal character. I have even resorted to trying to get ChatGPT and Meta AI to help lol -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried finding YouTube videos on riding systems/mounts/horses/rideable creatures and can’t find much, most are outdated. I’ve tried running my code through ChatGPT and this is the result of that
ETA: I’ve tried really hard not posting here because a lot of the old posts I look though suggest looking up a tutorial on YouTube and I didn’t find much there. I am a relatively new developer but I know the basics and have written a few working scripts but this one has me stumped and I am completely open to suggestions…
Forgot to add the hierarchy
Workspace
Unicorn
PrimaryPart
Seat (WeldConstraint to PrimaryPart)
BaseModel (WeldConstraint to PrimaryPart)
UnicornHumaniod
UnicornControScriptLocalControlScript
Unicorn (ObjectValue, ChatGPT suggestion)
-- Server Script: UnicornControl
local Unicorn = script.Parent
local seat = Unicorn:WaitForChild("Seat")
print("UnicornControl script loaded. Waiting for seat occupant change...")
seat.Changed:Connect(function(property)
print("Seat property changed: ", property)
local occupant = seat.Occupant
if occupant then
print("Seat occupied by: ", occupant.Parent.Name)
local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
if player then
print("Player found: ", player.Name)
local localControlScript = script:WaitForChild("LocalControlScript"):Clone()
localControlScript.Unicorn.Value = Unicorn
localControlScript.Parent = player.PlayerGui
localControlScript.Disabled = false
print("LocalControlScript cloned and parented to PlayerGui")
else
print("Player not found for occupant")
end
else
print("Seat is now unoccupied")
end
end)
This is a localscript named LocalControlScript which is a child of the UnicornControlScript
-- Local Script: LocalControlScript
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Unicorn = script:WaitForChild("Unicorn").Value
local UnicornHumanoid = Unicorn:WaitForChild("UnicornHumanoid")
local seat = Unicorn:WaitForChild("Seat")
print("LocalControlScript loaded for player: ", player.Name)
-- Ensure the PrimaryPart is set
if not Unicorn.PrimaryPart then
warn("Unicorn model does not have a PrimaryPart set!")
else
print("Unicorn PrimaryPart is set to: ", Unicorn.PrimaryPart.Name)
end
-- Ensure UnicornHumanoid is correctly set up
if not UnicornHumanoid then
warn("UnicornHumanoid not found in the Unicorn model!")
else
print("UnicornHumanoid found: ", UnicornHumanoid.Name)
end
local movement = Vector3.new(0, 0, 0)
local function onInputBegan(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Up then
movement = Vector3.new(movement.X, movement.Y, -1)
print("InputBegan: Move Forward")
elseif input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.Down then
movement = Vector3.new(movement.X, movement.Y, 1)
print("InputBegan: Move Backward")
elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Left then
movement = Vector3.new(-1, movement.Y, movement.Z)
print("InputBegan: Move Left")
elseif input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Right then
movement = Vector3.new(1, movement.Y, movement.Z)
print("InputBegan: Move Right")
elseif input.KeyCode == Enum.KeyCode.Space then
local ray = Ray.new(Unicorn.PrimaryPart.Position + Vector3.new(0, -4.3, 0), Vector3.new(0, -1, 0))
local hit, position = game.Workspace:FindPartOnRay(ray, Unicorn)
if hit and hit.CanCollide then
UnicornHumanoid:ChangeState(Enum.HumanoidStateType.Jumping)
print("InputBegan: Jump")
end
elseif input.KeyCode == Enum.KeyCode.LeftShift then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
print("InputBegan: Jump (Shift)")
end
end
local function onInputEnded(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Up then
if movement.Z < 0 then
movement = Vector3.new(movement.X, movement.Y, 0)
print("InputEnded: Stop Moving Forward")
end
elseif input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.Down then
if movement.Z > 0 then
movement = Vector3.new(movement.X, movement.Y, 0)
print("InputEnded: Stop Moving Backward")
end
elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Left then
if movement.X < 0 then
movement = Vector3.new(0, movement.Y, movement.Z)
print("InputEnded: Stop Moving Left")
end
elseif input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Right then
if movement.X > 0 then
movement = Vector3.new(0, movement.Y, movement.Z)
print("InputEnded: Stop Moving Right")
end
end
end
userInputService.InputBegan:Connect(onInputBegan)
userInputService.InputEnded:Connect(onInputEnded)
spawn(function()
print("Starting movement control loop")
while seat.Occupant == humanoid do
game:GetService("RunService").RenderStepped:Wait()
if UnicornHumanoid then
if movement.Magnitude > 0 then
UnicornHumanoid:Move(movement, true)
print("Moving Unicorn: ", movement)
else
UnicornHumanoid:Move(Vector3.new(), true)
print("Stopping Unicorn")
end
else
print("UnicornHumanoid not found!")
end
end
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
if UnicornHumanoid then
UnicornHumanoid:Move(Vector3.new(), true)
end
print("Stopped movement control loop")
script:Destroy()
end)