local function WeldTwoParts(A, B, P)
local weld = Instance.new(“WeldConstraint”, P)
weld.Parent = workspace
weld.Part0 = A
weld.Part1 = B
end
wait(2)
local Camera = workspace.CurrentCamera
local UserInputService = game:GetService(“UserInputService”)
local Player = game.Players.LocalPlayer
local Character = Player.Character
for i,v in pairs(Character:GetChildren())do
if v:IsA("BasePart")then
v.CanCollide = false
end
end
if not Character or not Character.Parent then
Character = Player.CharacterAdded:wait()
end
local density = .3
local friction = .1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1
local HRP = Character.PrimaryPart
local Marble = Instance.new("Part", workspace)
Marble.CFrame = CFrame.new(0,10,0)
Marble.Size = Vector3.new(11,11,11)
Marble.Transparency = 0.5
Marble.Shape = Enum.PartType.Ball
Marble.FrontSurface = Enum.SurfaceType.Smooth
Marble.BackSurface = Enum.SurfaceType.Smooth
Marble.LeftSurface = Enum.SurfaceType.Smooth
Marble.RightSurface = Enum.SurfaceType.Smooth
Marble.TopSurface = Enum.SurfaceType.Smooth
Marble.BottomSurface = Enum.SurfaceType.Smooth
Marble.Name = "Marble"
Marble.CustomPhysicalProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
local Animation = Character.Animate
wait(1)
Animation.Disabled = true
workspace.Marble.CFrame = CFrame.new(0,10,0)
Character:SetPrimaryPartCFrame(CFrame.new(0,10,0))
WeldTwoParts(Character.PrimaryPart, Marble, HRP)
spawn(function()
local Attachment0 = Instance.new("Attachment", HRP)
local Attachment1 = Instance.new("Attachment", Marble)
local AlignOrientation = Instance.new("AlignOrientation", HRP)
AlignOrientation.Attachment0 = Attachment0
AlignOrientation.Attachment1 = Attachment1
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
local FakeUpVector = Vector3.new(0,1,0)
local RightVector = Camera.CFrame.LookVector:Cross(FakeUpVector)
local LeftVector = -RightVector
local ForwardVector = Character.Head.CFrame.LookVector+ Camera.CFrame.LookVector
– local Theta = math.acos(Character.Head.LookVector:Dot(Camera.CFrame.LookVector))
local BackVelocity = -ForwardVector
Attachment0.CFrame = HRP.CFrame
Attachment1.CFrame = Marble.CFrame
local key = input.KeyCode
if key == Enum.KeyCode.W then
local ForwardVelocityForce = Instance.new(“BodyVelocity”, Marble)
ForwardVelocityForce.Name = “ForwardVelocityForce”
ForwardVelocityForce.MaxForce = Vector3.new(100 ,100 ,100)
ForwardVelocityForce.Velocity = ForwardVector100
ForwardVelocityForce.P = 10
elseif key == Enum.KeyCode.A then
local LeftVelocityForce = Instance.new(“BodyVelocity”, Marble)
LeftVelocityForce.Name = “LeftVelocityForce”
LeftVelocityForce.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
LeftVelocityForce.P = 10
LeftVelocityForce.Velocity = LeftVector100
elseif key == Enum.KeyCode.D then
local RightVelocityForce = Instance.new(“BodyVelocity”, Marble)
RightVelocityForce.Name = “RightVelocityForce”
RightVelocityForce.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
RightVelocityForce.P = 10
RightVelocityForce.Velocity = RightVector100
elseif key == Enum.KeyCode.S then
local BackVelocityForce = Instance.new(“BodyVelocity”, Marble)
BackVelocityForce.Name = “BackVelocityForce”
BackVelocityForce.MaxForce = Vector3.new(100, 100, 100)
BackVelocityForce.P = 10
BackVelocityForce.Velocity = BackVelocity100
end
end)
– while true do
– wait(0.5)
– Attachment0.CFrame = HRP.CFrame
– Attachment1.CFrame = Marble.CFrame
– end
UserInputService.InputEnded:Connect(function(input, gameProcessedEvent)
local key = input.KeyCode
if key == Enum.KeyCode.W then
if Marble:FindFirstChild("ForwardVelocityForce") then
Marble.ForwardVelocityForce:Destroy()
end
end
if key == Enum.KeyCode.A then
if Marble:FindFirstChild("LeftVelocityForce") then
Marble.LeftVelocityForce:Destroy()
end
end
if key == Enum.KeyCode.D then
if Marble:FindFirstChild("RightVelocityForce") then
Marble.RightVelocityForce:Destroy()
end
end
if key == Enum.KeyCode.S then
if Marble:FindFirstChild("BackVelocityForce") then
Marble.BackVelocityForce:Destroy()
end
end
end)
end)