Basically, there are 2 characters, a teammate and the character, one is a boulder without controlls and the other is a player. Im writing a script to roll the ball infront of the player at all times, it needs to roll and be able to be pushed up surfaces (Im pretty sure this rules out just setting its pos infront of the player). This is what it looks like: Watch Place1 - Roblox Studio 2025-02-06 20-37-37 | Streamable
This is the script:
game.ReplicatedStorage.BoulderEvent.OnServerEvent:Connect(function(Plr, F)
local Tmate = nil
for i,v in pairs(Plr:GetTags()) do
if game.Players:FindFirstChild(v) then
Tmate = game.Players:FindFirstChild(v)
end
end
if Tmate:IsA("Player") then
if F == "Roll" then
Tmate.Character.HumanoidRootPart.Touched:Connect(function(pPart)
if game.Players:GetPlayerFromCharacter(pPart.Parent) then
Plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
wait(0.5)
Plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, true)
end
end)
Tmate.Character.HumanoidRootPart.CollisionGroup = "Players"
local Att = Instance.new("Attachment")
Att.Name = "Attachment0"
Att.Parent = Tmate.Character.HumanoidRootPart
Att.Position = Vector3.new(0,0,0)
local AP = Instance.new("AlignPosition")
AP.Name = "AlignPosition"
AP.Parent = Tmate.Character.HumanoidRootPart
AP.Mode = "OneAttachment"
AP.Attachment0 = Att
AP.ApplyAtCenterOfMass = true
AP.ReactionForceEnabled = true
AP.MaxForce = 500000000
AP.Responsiveness = 200
local OldHRPOri = nil
OldHRPOri = Plr.Character.HumanoidRootPart.Orientation
game:GetService("RunService").Heartbeat:Connect(function()
local char = Tmate.Character
local marble = char.HumanoidRootPart
if (OldHRPOri - Plr.Character.HumanoidRootPart.Orientation).Magnitude <= 5 or Plr.Character.Humanoid.MoveDirection == Vector3.new(0,0,0) then
print("ASASASSASA")
marble.BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)
end
OldHRPOri = Plr.Character.HumanoidRootPart.Orientation
AP.Position = Vector3.new(Plr.Character.HumanoidRootPart.Position.X,Plr.Character.HumanoidRootPart.Position.Y - 5,Plr.Character.HumanoidRootPart.Position.Z) + Plr.Character.HumanoidRootPart.CFrame.LookVector * (Plr.Character.Humanoid.MoveDirection * Vector3.new(6,0,6) + Vector3.new(7,0,7))
marble.BodyAngularVelocity.AngularVelocity = Vector3.new(Plr.Character.Humanoid.MoveDirection.z * 32,0,Plr.Character.Humanoid.MoveDirection.x * -32)
marble.BodyAngularVelocity.MaxTorque = Vector3.new(30000,30000,30000)
end)
else
end
end
end)