local limbs = LoadAssets(14303195352):GetDictionary()
local head = limbs.head:Clone()
local leftHand = limbs.limb:Clone()
local rightHand = leftHand:Clone()
do
local face = Instance.new("Decal")
face.Texture = "rbxasset://textures/face.png"
face.Parent = head
end
local positionalPairPart = Instance.new("Part", script)
positionalPairPart.Anchored = true
positionalPairPart.CanCollide = false
positionalPairPart.Transparency = 1
positionalPairPart.CFrame = CFrame.new()
function CreatePositionalPair(m)
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.Mode = Enum.PositionAlignmentMode.TwoAttachment
AlignPosition.Responsiveness = 200
local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Mode = Enum.OrientationAlignmentMode.TwoAttachment
AlignOrientation.Responsiveness = 200
local PositionAttachment0 = Instance.new("Attachment")
PositionAttachment0.Parent = m
local PositionAttachment1 = PositionAttachment0:Clone()
PositionAttachment1.Parent = positionalPairPart
local RotationAttachment0 = PositionAttachment0:Clone()
RotationAttachment0.Parent = m
local RotationAttachment1 = PositionAttachment0:Clone()
RotationAttachment1.Parent = positionalPairPart
AlignOrientation.Attachment0 = RotationAttachment0
AlignOrientation.Attachment1 = RotationAttachment1
AlignPosition.Attachment0 = PositionAttachment0
AlignPosition.Attachment1 = PositionAttachment1
return setmetatable({}, {
__newindex = function(self, idx, val)
if idx == "CFrame" then
PositionAttachment1.CFrame = val
RotationAttachment1.CFrame = val
end
end,
__index = function(self, idx)
if idx == "CFrame" then
return PositionAttachment1.CFrame
elseif idx == "Part" then
return m
end
end,
})
end
local headSetter = CreatePositionalPair(head)
local leftHandSetter = CreatePositionalPair(leftHand)
local rightHandSetter = CreatePositionalPair(rightHand)
headSetter.CFrame = CFrame.new(0, 30, 0)
leftHandSetter.CFrame = CFrame.new(-1, 25, 0)
rightHandSetter.CFrame = CFrame.new(1, 25, 0)
local physService = game:GetService("PhysicsService")
physService:RegisterCollisionGroup("VRAnchoredParts")
physService:CollisionGroupSetCollidable("VRAnchoredParts", "VRAnchoredParts", false)
head.CollisionGroup = "VRAnchoredParts"
leftHand.CollisionGroup = "VRAnchoredParts"
rightHand.CollisionGroup = "VRAnchoredParts"
for i, v in workspace:GetDescendants() do
if v:IsDescendantOf(script) == true or v:IsA("BasePart") == false or v.Anchored == false then
continue
end
pcall(function()
v.CollisionGroup = "VRAnchoredParts"
end)
end
workspace.DescendantAdded:Connect(function(desc)
if desc:IsA("BasePart") and desc.Anchored == true and not desc:IsDescendantOf(script) then
desc.CollisionGroup = "VRAnchoredParts"
end
end)
local objRemote = Instance.new("RemoteFunction")
objRemote.Parent = owner.PlayerGui
NLS([[
local obj = script.Parent
local head, leftArm, rightArm = obj:InvokeServer("GetObjects")
local vrservice = game:service'VRService'
local runservice = game:service'RunService'
if vrservice.VREnabled == false then
return warn("vr not enabled")
end
local cam = workspace.CurrentCamera
vrservice:RecenterUserHeadCFrame()
cam.CFrame = CFrame.new(cam.CFrame.Position)
local headScale = 3
obj:InvokeServer("SetScale", headScale)
local lasthp = vrservice:GetUserCFrame("Head").Position
function multiplyCFrame(_CFrame, Multiplier)
local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = _CFrame:GetComponents()
return CFrame.new(x * Multiplier, y * Multiplier, z * Multiplier, R00, R01, R02, R10, R11, R12, R20, R21, R22)
end
runservice.RenderStepped:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.HeadScale = headScale
cam.FieldOfView = 89
local headcf, lacf, racf = vrservice:GetUserCFrame("Head"), vrservice:GetUserCFrame("LeftHand"), vrservice:GetUserCFrame("RightHand")
local mhcf = multiplyCFrame(headcf, headScale)
local cr = CFrame.fromEulerAnglesXYZ(mhcf:ToEulerAnglesXYZ()) * mhcf:Inverse()
local shcf, slcf, srcf = cr * mhcf, cr * multiplyCFrame(lacf, headScale), cr * multiplyCFrame(racf, headScale)
cam.CFrame = CFrame.new(shcf.Position) * cr
head.Part.LocalTransparencyModifier = 1
end)
]], objRemote)
objRemote.OnServerInvoke = function(plr, c, ...)
local args = {...}
if c == "SetScale" then
head.Size = Vector3.one * args[1]
leftHand.Size = Vector3.new(1,2,1) * args[1]
rightHand.Size = leftHand.Size
return
end
if c == "GetObjects" then
head.Anchored = false
leftHand.Anchored = false
rightHand.Anchored = false
head.Parent = script
leftHand.Parent = script
rightHand.Parent = script
head:SetNetworkOwner(owner)
leftHand:SetNetworkOwner(owner)
rightHand:SetNetworkOwner(owner)
return headSetter, leftHandSetter, rightHandSetter
end
end
local ObjectEvent = script.Parent
task.wait()
script:Destroy()
local Head, LeftArm, RightArm, Character = ObjectEvent:InvokeServer("getLimbs")
local VRService = game:GetService("VRService")
if VRService.VREnabled == false then
ObjectEvent:InvokeServer("hi can u fuck off ok thx")
return warn("VR not enabled.")
end
local IsTurning = false
local Turn = CFrame.fromEulerAnglesXYZ(0, 0, 0)
local ThumbStickMovement = Vector3.zero
local ThumbStickY = 0
local NoCollided = {}
local NoCollideOverlapParams = OverlapParams.new()
NoCollideOverlapParams.MaxParts = nil
NoCollideOverlapParams.FilterType = Enum.RaycastFilterType.Exclude
local Workspace = workspace
for _, Accessory in ipairs(Character:GetChildren()) do
if not Accessory:IsA("Accessory") then
continue
end
local Handle = Accessory:FindFirstChild("Handle")
if not Handle then
continue
end
Handle.LocalTransparencyModifier = 1
end
VRService:RecenterUserHeadCFrame()
workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position)
local CameraPosition = Workspace.CurrentCamera.CFrame
local LastHeadPosition = VRService:GetUserCFrame(Enum.UserCFrame.Head).Position
local CharacterData = {
Scale = 3,
LeftArmMode = "Collide",
RightArmMode = "Collide"
}
local UncollisionDistance = 5
function UncollideWithAnchored(Limb)
for _, BasePart in ipairs(Workspace:GetPartBoundsInRadius(Limb.Position, CharacterData.Scale * UncollisionDistance, NoCollideOverlapParams)) do
if (not BasePart.Anchored or not BasePart.CanCollide) and not BasePart.Parent:FindFirstChildOfClass("Humanoid") then
continue
end
if NoCollided[BasePart] then
continue
end
NoCollided[BasePart] = true
local LeftNCC = Instance.new("NoCollisionConstraint")
LeftNCC.Part0 = LeftArm
LeftNCC.Part1 = BasePart
LeftNCC.Parent = BasePart
local RightNCC = Instance.new("NoCollisionConstraint")
RightNCC.Part0 = RightArm
RightNCC.Part1 = BasePart
RightNCC.Parent = BasePart
task.defer(function()
while BasePart.Parent and ((BasePart.Anchored and BasePart.CanCollide) or BasePart.Parent:FindFirstChildOfClass("Humanoid")) and NoCollided[BasePart] do
task.wait(1)
end
LeftNCC:Destroy()
RightNCC:Destroy()
NoCollided[BasePart] = nil
end)
end
end
function MultiplyCFrame(_CFrame, Multiplier)
local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = _CFrame:GetComponents()
return CFrame.new(x * Multiplier, y * Multiplier, z * Multiplier, R00, R01, R02, R10, R11, R12, R20, R21, R22)
end
local Math = {}
function Math.lerp(a, b, t)
return a + (b-a) * t
end
local HoldingA, HoldingB = false, false
local UserInputService = game:GetService("UserInputService")
function HandleThumbstick1(Input)
ThumbStickMovement = Vector3.new(Input.Position.X, 0, -Input.Position.Y)
end
function HandleThumbstick2(Input)
if not IsTurning and math.abs(Input.Position.X) >= 0.7 then
IsTurning = true
Turn *= CFrame.fromEulerAnglesXYZ(0, math.pi * 0.5 * -math.sign(Input.Position.X), 0)
elseif IsTurning and math.abs(Input.Position.X) < 0.7 then
IsTurning = false
end
if math.abs(Input.Position.Y) >= 0.35 then
ThumbStickY = Input.Position.Y
else
ThumbStickY = 0
end
end
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType ~= Enum.UserInputType.Gamepad1 then
return
end
local KeyCode = Input.KeyCode
if KeyCode == Enum.KeyCode.Thumbstick1 then
HandleThumbstick1(Input)
elseif KeyCode == Enum.KeyCode.Thumbstick2 then
HandleThumbstick2(Input)
elseif KeyCode == Enum.KeyCode.ButtonA then
HoldingA = true
elseif KeyCode == Enum.KeyCode.ButtonB then
HoldingB = true
elseif KeyCode == Enum.KeyCode.ButtonY then
elseif KeyCode == Enum.KeyCode.ButtonX then
end
end)
UserInputService.InputChanged:Connect(function(Input)
if Input.UserInputType ~= Enum.UserInputType.Gamepad1 then
return
end
local KeyCode = Input.KeyCode
if KeyCode == Enum.KeyCode.Thumbstick1 then
HandleThumbstick1(Input)
elseif KeyCode == Enum.KeyCode.Thumbstick2 then
HandleThumbstick2(Input)
end
end)
UserInputService.InputEnded:Connect(function(Input)
if Input.UserInputType ~= Enum.UserInputType.Gamepad1 then
return
end
local KeyCode = Input.KeyCode
if KeyCode == Enum.KeyCode.Thumbstick1 then
HandleThumbstick1(Input)
elseif KeyCode == Enum.KeyCode.Thumbstick2 then
HandleThumbstick2(Input)
elseif KeyCode == Enum.KeyCode.ButtonA then
HoldingA = false
elseif KeyCode == Enum.KeyCode.ButtonB then
HoldingB = false
end
end)
task.defer(function()
while task.wait(1) do
local LeftArmCollisions = LeftArm and Workspace:GetPartBoundsInRadius(LeftArm.Position, CharacterData.Scale * UncollisionDistance, NoCollideOverlapParams) or {}
local RightArmCollisions = RightArm and Workspace:GetPartBoundsInRadius(RightArm.Position, CharacterData.Scale * UncollisionDistance, NoCollideOverlapParams) or {}
for Part, _ in pairs(NoCollided) do
if not table.find(LeftArmCollisions, Part) and not table.find(RightArmCollisions, Part) then
NoCollided[Part] = nil
end
task.wait()
end
end
end)
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function(dt)
local Scale = CharacterData.Scale * 3
local HeadCFrame, LeftHandCFrame, RightHandCFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head), VRService:GetUserCFrame(Enum.UserCFrame.LeftHand), VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
local MoveVector = Turn * CFrame.new(HeadCFrame.Position - LastHeadPosition).Position
CameraPosition = CameraPosition + MoveVector * Scale
CameraPosition = CFrame.new(CameraPosition.X, math.clamp(CameraPosition.Y, -100, 500), CameraPosition.Z) * (CameraPosition - CameraPosition.Position)
LastHeadPosition = HeadCFrame.Position
local MultipliedHeadCFrame = MultiplyCFrame(HeadCFrame, Scale)
local CameraRotation = Turn * CFrame.fromEulerAnglesXYZ(MultipliedHeadCFrame:ToEulerAnglesXYZ()) * MultipliedHeadCFrame:Inverse()
local CameraCFrame = CameraPosition * CameraRotation
local ScaledHeadCFrame, ScaledLeftHandCFrame, ScaledRightHandCFrame = CameraCFrame * MultipliedHeadCFrame, CameraCFrame * MultiplyCFrame(LeftHandCFrame, Scale), CameraCFrame * MultiplyCFrame(RightHandCFrame, Scale)
Head.CFrame = ScaledHeadCFrame
LeftArm.CFrame = ScaledLeftHandCFrame
RightArm.CFrame = ScaledRightHandCFrame
local Velocity = Vector3.zero
local CurrentCamera = Workspace.CurrentCamera
CurrentCamera.CFrame = CFrame.new(Head.Position) * CameraRotation
CurrentCamera.HeadScale = Scale
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.FieldOfView = 70
CurrentCamera.CFrame = CFrame.new(Head.Position) * CameraRotation
CurrentCamera.CameraSubject = nil
if ThumbStickMovement.Magnitude >= 0.15 then
local CameraLookVector = CurrentCamera:GetRenderCFrame().LookVector
Velocity = ((CFrame.fromEulerAnglesXYZ(0, math.atan2(-CameraLookVector.X, -CameraLookVector.Z), 0) * CFrame.new(ThumbStickMovement)).Position + Vector3.new(0, ThumbStickY, 0))
else
Velocity = Vector3.new(0, ThumbStickY, 0)
end
CameraPosition += (Velocity * 0.2 * (dt * 60)) * Scale
if Head then
Head.CanCollide = false
Head.LocalTransparencyModifier = 1
end
if LeftArm then
if CharacterData.LeftArmMode == "Collide" then
LeftArm.realpart.CanCollide = true
UncollideWithAnchored(LeftArm.realpart)
else
LeftArm.realpart.CanCollide = false
end
end
if RightArm then
if CharacterData.RightArmMode == "Collide" then
RightArm.realpart.CanCollide = true
UncollideWithAnchored(RightArm.realpart)
else
RightArm.realpart.CanCollide = false
end
end
end)