-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSkyVRHatdrop.lua
More file actions
307 lines (284 loc) · 11.7 KB
/
SkyVRHatdrop.lua
File metadata and controls
307 lines (284 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
local function createpart(size, name,h)
local Part = Instance.new("Part")
Part.Parent = workspace
Part.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
Part.Size = size
Part.Transparency = 1
Part.CanCollide = false
Part.Anchored = true
Part.Name = name
return Part
end
local ps = game:GetService("RunService").PostSimulation
local input = game:GetService("UserInputService")
local fpdh = game.Workspace.FallenPartsDestroyHeight
local Player = game.Players.LocalPlayer
local options = getgenv().options
local lefthandpart = createpart(Vector3.new(2,1,1), "moveRH",true)
local righthandpart = createpart(Vector3.new(2,1,1), "moveRH",true)
local headpart = createpart(Vector3.new(1,1,1), "moveH",false)
local lefttoypart = createpart(Vector3.new(1,1,1), "LToy",true)
local righttoypart = createpart(Vector3.new(1,1,1), "RToy",true)
local thirdperson = false
local lefttoyenable = false
local righttoyenable = false
local lfirst = true
local rfirst = true
local ltoypos = CFrame.new(1.15,0,0) * CFrame.Angles(0,math.rad(180),0)
local rtoypos = CFrame.new(1.15,0,0) * CFrame.Angles(0,math.rad(0),0)
local parts = {
left=lefthandpart,
right=righthandpart,
headhats=headpart,
leftToy=lefttoypart,
rightToy=righttoypart,
}
_isnetworkowner = function(v)
local success, result = pcall(function()
return v.ReceiveAge == 0 and not v.NetworkIsSleeping
end)
if success then
return result
else
return v.ReceiveAge
end
end
game.Workspace.FallenPartsDestroyHeight=0/0
function filterMeshID(id)
return (string.find(id,'assetdelivery')~=nil and string.match(string.sub(id,37,#id),"%d+")) or string.match(id,"%d+")
end
function findMeshID(id)
for i,v in pairs(getgenv().headhats) do
if i=="meshid:"..id then return true,"headhats" end
end
if getgenv().right=="meshid:"..id then return true,"right" end
if getgenv().left=="meshid:"..id then return true,"left" end
if options.leftToy=="meshid:"..id then return true,"leftToy" end
if options.rightToy=="meshid:"..id then return true,"rightToy" end
return false
end
function findHatName(id)
for i,v in pairs(getgenv().headhats) do
if i==id then return true,"headhats" end
end
if getgenv().right==id then return true,"right" end
if getgenv().left==id then return true,"left" end
if options.leftToy==id then return true,"leftToy" end
if options.rightToy==id then return true,"rightToy" end
return false
end
function Align(Part1,Part0,cf,isflingpart)
local up = isflingpart
local con;con=ps:Connect(function()
if up~=nil then up=not up end
if not Part1:IsDescendantOf(workspace) then con:Disconnect() return end
if not _isnetworkowner(Part1) then return end
Part1.CanCollide=false
Part1.CFrame=Part0.CFrame*cf
Part1.Velocity = velocity or Vector3.new(20,20,20)
end)
return {SetVelocity = function(self,v) velocity=v end,SetCFrame = function(self,v) cf=v end,}
end
function getAllHats(Character)
local allhats = {}
local foundmeshids = {}
for i,v in pairs(Character:GetChildren()) do
if not v:IsA"Accessory" then continue end
if not v.Handle:FindFirstChildOfClass("SpecialMesh") then continue end
local is,d = findMeshID(filterMeshID(v.Handle:FindFirstChildOfClass("SpecialMesh").MeshId))
if foundmeshids["meshid:"..filterMeshID(v.Handle:FindFirstChildOfClass("SpecialMesh").MeshId)] then is = false else foundmeshids["meshid:"..filterMeshID(v.Handle:FindFirstChildOfClass("SpecialMesh").MeshId)] = true end
if is then
table.insert(allhats,{v,d,"meshid:"..filterMeshID(v.Handle:FindFirstChildOfClass("SpecialMesh").MeshId)})
else
local is,d = findHatName(v.Name)
if not is then continue end
table.insert(allhats,{v,d,v.Name})
end
end
return allhats
end
pcall(function()
sethiddenproperty(hum, "InternalBodyScale", Vector3.new(9e9,9e9,9e9))
end)
pcall(function()
sethiddenproperty(ws, "PhysicsSteppingMethod", Enum.PhysicsSteppingMethod.Fixed)
end)
pcall(function()
ws.InterpolationThrottling = Enum.InterpolationThrottlingMode.Disabled
end)
pcall(function()
ws.Retargeting = "Disabled"
end)
pcall(function()
sethiddenproperty(ws, "SignalBehavior", "Immediate")
end)
pcall(function()
game:GetService("PhysicsSettings").PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.Disabled
end)
pcall(function()
game:GetService("PhysicsSettings").AllowSleep = false
end)
pcall(function()
game:GetService("PhysicsSettings").ThrottleAdjustTime = math.huge
end)
pcall(function()
game:GetService("PhysicsSettings").ForceCSGv2 = false
end)
pcall(function()
game:GetService("PhysicsSettings").DisableCSGv2 = false
end)
pcall(function()
game:GetService("PhysicsSettings").UseCSGv2 = false
end)
pcall(function()
game:GetService("PhysicsSettings").UseCSGv2 = false
end)
pcall(function()
setsimulationradius(math.huge)
end)
pcall(function()
p.MaximumSimulationRadius = 9e9
p.SimulationRadius = 9e9
end)
local function fullbreakvel(instance)
local instance = instance or p.Character
local part = instance and (instance:IsA("BasePart") and instance or instance:IsA("Model") and (instance.PrimaryPart or instance:FindFirstChildWhichIsA("BasePart")) or instance:FindFirstChildWhichIsA("BasePart"))
if not part then
return
end
part.AssemblyAngularVelocity = Vector3.new()
part.AssemblyLinearVelocity = Vector3.new()
for i, v in part:GetConnectedParts(true) do
v.AssemblyAngularVelocity = Vector3.new()
v.AssemblyLinearVelocity = Vector3.new()
end
end
function HatdropCallback(Character, callback)
Character:WaitForChild("Humanoid")
Character:WaitForChild("HumanoidRootPart")
task.wait(0.4)
local AnimationInstance = Instance.new("Animation");AnimationInstance.AnimationId = "rbxassetid://35154961"
workspace.FallenPartsDestroyHeight = 0/0
local hrp = Character.HumanoidRootPart
local startCF = Character.HumanoidRootPart.CFrame
local torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("LowerTorso")
local Track = Character.Humanoid.Animator:LoadAnimation(AnimationInstance)
Track:Play()
Track.TimePosition = 3.24
Track:AdjustSpeed(0)
local locks = {}
for i,v in pairs(Character.Humanoid:GetAccessories()) do
table.insert(locks,v.Changed:Connect(function(p)
if p == "BackendAccoutrementState" then
sethiddenproperty(v,"BackendAccoutrementState",0)
end
end))
sethiddenproperty(v,"BackendAccoutrementState",2)
end
local c;c=game:GetService("RunService").PostSimulation:Connect(function()
if(not Character:FindFirstChild("HumanoidRootPart"))then c:Disconnect()return;end
hrp.Velocity = Vector3.new(0,0,25)
hrp.RotVelocity = Vector3.new(0,0,0)
hrp.CFrame = CFrame.new(startCF.X,fpdh+.25,startCF.Z) * (Character:FindFirstChild("Torso") and CFrame.Angles(math.rad(90),0,0) or CFrame.new())
end)
task.wait(.35)
callback(getAllHats(Character))
Character.Humanoid:ChangeState(15)
torso.AncestryChanged:Wait()
for i,v in pairs(locks) do
v:Disconnect()
end
for i,v in pairs(Character.Humanoid:GetAccessories()) do
sethiddenproperty(v,"BackendAccoutrementState",4)
end
end
local cam = workspace.CurrentCamera
game:GetService("StarterGui"):SetCore("VREnableControllerModels", false)
local rightarmalign = nil
getgenv().con5 = input.UserCFrameChanged:connect(function(part,move)
cam.CameraType = "Scriptable"
cam.HeadScale = options.headscale
if part == Enum.UserCFrame.Head then
headpart.CFrame = cam.CFrame*(CFrame.new(move.p*(cam.HeadScale-1))*move)
--thirdpersonpart.CFrame = cam.CFrame * (CFrame.new(move.p*(cam.HeadScale-1))*move) * CFrame.new(0,0,-10) * CFrame.Angles(math.rad(180),0,math.rad(180))
elseif part == Enum.UserCFrame.LeftHand then
lefthandpart.CFrame = cam.CFrame*(CFrame.new(move.p*(cam.HeadScale-1))*move*CFrame.Angles(math.rad(options.lefthandrotoffset.X),math.rad(options.lefthandrotoffset.Y),math.rad(options.lefthandrotoffset.Z)))
if lefttoyenable then
lefttoypart.CFrame = lefthandpart.CFrame * ltoypos
end
elseif part == Enum.UserCFrame.RightHand then
righthandpart.CFrame = cam.CFrame*(CFrame.new(move.p*(cam.HeadScale-1))*move*CFrame.Angles(math.rad(options.righthandrotoffset.X),math.rad(options.righthandrotoffset.Y),math.rad(options.righthandrotoffset.Z)))
if righttoyenable then
righttoypart.CFrame = righthandpart.CFrame * rtoypos
end
end
end)
getgenv().con4 = input.InputBegan:connect(function(key)
if key.KeyCode == options.thirdPersonButtonToggle then
thirdperson = not thirdperson -- disabled?
end
if key.KeyCode == Enum.KeyCode.ButtonR1 then
R1down = true
end
if key.KeyCode == options.leftToyBind then
if not lfirst then
ltoypos = lefttoypart.CFrame:ToObjectSpace(lefthandpart.CFrame):Inverse()
end
lfirst = false
lefttoyenable = not lefttoyenable
end
if key.KeyCode == options.rightToyBind then
if not rfirst then
rtoypos = righttoypart.CFrame:ToObjectSpace(righthandpart.CFrame):Inverse()
end
rfirst = false
righttoyenable = not righttoyenable
end
if key.KeyCode == Enum.KeyCode.ButtonR2 and rightarmalign~=nil then
R2down = true
end
end)
getgenv().con3 = input.InputEnded:connect(function(key)
if key.KeyCode == Enum.KeyCode.ButtonR1 then
R1down = false
end
if key.KeyCode == Enum.KeyCode.ButtonR2 and rightarmalign~=nil then
R2down = false
end
end)
local negitive = true
getgenv().con2 = game:GetService("RunService").RenderStepped:connect(function()
-- righthandpart.CFrame*CFrame.Angles(-math.rad(options.righthandrotoffset.X),-math.rad(options.righthandrotoffset.Y),math.rad(180-options.righthandrotoffset.X))
if R1down then
cam.CFrame = cam.CFrame:Lerp(cam.CoordinateFrame + (righthandpart.CFrame * CFrame.Angles(math.rad(options.righthandrotoffset.X),math.rad(options.righthandrotoffset.Y),math.rad(options.righthandrotoffset.Z)):Inverse() * CFrame.Angles(math.rad(options.controllerRotationOffset.X),math.rad(options.controllerRotationOffset.Y),math.rad(options.controllerRotationOffset.Z))).LookVector * cam.HeadScale/2, 0.5)
end
if R2down and rightarmalign then
negitive=not negitive
rightarmalign:SetVelocity(Vector3.new(0,0,-99999999))
rightarmalign:SetCFrame(CFrame.Angles(math.rad(options.righthandrotoffset.X),math.rad(options.righthandrotoffset.Y),math.rad(options.righthandrotoffset.Z)):Inverse()*CFrame.new(0,0,8*(negitive and -1 or 1)))
elseif rightarmalign then
rightarmalign:SetVelocity(Vector3.new(20,20,20))
rightarmalign:SetCFrame(CFrame.new(0,0,0))
end
end)
local s,e = pcall(function()
HatdropCallback(Player.Character, function(allhats)
for i,v in pairs(allhats) do
if not v[1]:FindFirstChild("Handle") then continue end
if v[2]=="headhats" then v[1].Handle.Transparency = options.HeadHatTransparency or 1 end
local align = Align(v[1].Handle,parts[v[2]],((v[2]=="headhats")and getgenv()[v[2]][(v[3])]) or CFrame.identity)
rightarmalign = v[2]=="right" and align or rightarmalign
end
end)
end)
if not s then print(e) end
getgenv().conn = Player.CharacterAdded:Connect(function(Character)
HatdropCallback(Player.Character, function(allhats)
for i,v in pairs(allhats) do
if not v[1]:FindFirstChild("Handle") then continue end
if v[2]=="headhats" then v[1].Handle.Transparency = options.HeadHatTransparency or 1 end
local align = Align(v[1].Handle,parts[v[2]],((v[2]=="headhats")and getgenv()[v[2]][(v[3])]) or CFrame.identity)
rightarmalign = v[2]=="right" and align or rightarmalign
end
end)
end)