So i have a ball socket constraint connected between a player and a ball (Both are plrs) The ball should roll infront of the player. The ball just has to roll forward infront of the plr, Here is my code:
game.ReplicatedStorage.BoulderEvent.OnServerEvent:Connect(function(Plr, F)
local Kill = false
local Tmate = nil
for i,v in pairs(Plr:GetTags()) do
if game.Players:FindFirstChild(v) then
Tmate = game.Players:FindFirstChild(v)
end
end
local plrRoot = Plr.Character:FindFirstChild("HumanoidRootPart")
local tmateRoot = Tmate.Character:FindFirstChild("HumanoidRootPart")
if Tmate:IsA("Player") then
if F == "Roll" then
local Part = Instance.new("Part")
Part.Name = "ReferencePart"
Part.Parent = tmateRoot
Part.Position = tmateRoot.Position
Part.Transparency = 1
Part.CanCollide = false
Part.Massless = true
local Weld = Instance.new("WeldConstraint")
Weld.Name = "RidgedWeld"
Weld.Parent = plrRoot
Weld.Part0 = plrRoot
Weld.Part1 = tmateRoot
tmateRoot.Position = Vector3.new(3,0,3) * plrRoot.CFrame.LookVector + plrRoot.Position - Vector3.new(0,0.9,0)
local plrAttachment = Instance.new("Attachment")
plrAttachment.Name = "RigidAttachment"
plrAttachment.Parent = Part
local tmateAttachment = Instance.new("Attachment")
tmateAttachment.Name = "RotatingAttachment"
tmateAttachment.Parent = tmateRoot
local ballSocket = Instance.new("BallSocketConstraint")
ballSocket.Name = "BallSocketConstraint"
ballSocket.Attachment0 = plrAttachment
ballSocket.Attachment1 = tmateAttachment
ballSocket.Parent = plrRoot
tmateRoot.Massless = true
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.01, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local lastPosition = tmateRoot.Position
repeat
local Speed = (tmateRoot.Position - lastPosition).Magnitude * 10
-- Add spin here
until Kill
else
Kill = true
end
Thanks for any help!