Repository navigation
Expand file tree
/
Copy pathrocketLauncher.lua
More file actions
141 lines (110 loc) · 4.48 KB
/
Copy pathrocketLauncher.lua
File metadata and controls
141 lines (110 loc) · 4.48 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
local Functions = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Functions.lua"))()
local debrisService = game:GetService("Debris")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local rocketLauncher = game:GetObjects("rbxassetid://13602301356")[1]
local BoomSound = rocketLauncher:WaitForChild("Boom")
local SwooshSound = rocketLauncher:WaitForChild("Swoosh")
local Rocket = Instance.new("Part") do
Rocket.Name = "Rocket"
Rocket.FormFactor = Enum.FormFactor.Custom
Rocket.Size = Vector3.new(1.2, 1.2, 3.27)
Rocket.CanCollide = false
local mesh = Instance.new("SpecialMesh", Rocket)
mesh.MeshId = "rbxassetid://2251534"
mesh.Scale = Vector3.new(0.35, 0.35, 0.25)
local fire = Instance.new("Fire", Rocket)
fire.Heat = 5
fire.Size = 2
local bodyForce = Instance.new("BodyForce", Rocket)
bodyForce.Force = Vector3.new(0, Rocket:GetMass() * workspace.Gravity, 0)
end
rocketLauncher.Parent = player.Backpack
rocketLauncher.Activated:Connect(function()
local swooshSoundClone = SwooshSound:Clone()
swooshSoundClone.Parent = game:GetService("ReplicatedStorage")
local boomSoundClone = BoomSound:Clone()
boomSoundClone.Parent = game:GetService("ReplicatedStorage")
local Pos = mouse.Hit.p
local rocketClone = Rocket:Clone()
rocketClone.BrickColor = BrickColor.Gray()
debrisService:AddItem(rocketClone, 10)
swooshSoundClone:Play()
local spawnPosition = (rocketLauncher.Handle.CFrame * CFrame.new(5, 0, 0)).p
rocketClone.CFrame = CFrame.new(spawnPosition, Pos)
rocketClone.Velocity = rocketClone.CFrame.lookVector * 60
rocketClone.Parent = workspace
task.spawn(function()
repeat task.wait() until not rocketClone:IsDescendantOf(workspace) or rocketClone == nil
swooshSoundClone.Volume = 0
swooshSoundClone:Stop()
swooshSoundClone:Destroy()
if not boomSoundClone.isPlaying then
boomSoundClone:Stop()
boomSoundClone:Destroy()
end
end)
rocketClone.Touched:Connect(function()
local rocketCloneCFrame = rocketClone.CFrame
local rocketClonePos = rocketClone.Position
rocketClone:Destroy()
task.spawn(function()
swooshSoundClone.Volume = 0
swooshSoundClone:Stop()
swooshSoundClone:Destroy()
boomSoundClone:Play()
boomSoundClone.Ended:Wait()
boomSoundClone.Volume = 0
boomSoundClone:Stop()
boomSoundClone:Destroy()
end)
local explosion = Instance.new('Explosion')
explosion.BlastPressure = 0
explosion.BlastRadius = 8
explosion.ExplosionType = Enum.ExplosionType.NoCraters
explosion.Position = rocketClonePos
explosion.Parent = workspace
local parts = workspace:GetPartBoundsInBox(rocketCloneCFrame,Vector3.new(10,10,10))
local forceTable = {}
for _, part in ipairs(parts) do
if string.find(part.Name,"Wall") or string.find(part.Name,"Floor") then
continue
end
part.Anchored = false
local bodyforce = Instance.new("BodyVelocity",part)
bodyforce.Velocity = (((15 - (part.Position - rocketClonePos).Magnitude) * 100) * (part.Position - rocketClonePos).Unit)
table.insert(forceTable,bodyforce)
part.CFrame = part.CFrame * CFrame.new(math.random(1,5),0,math.random(1,5))
end
task.wait(0.25)
for _,force in pairs(forceTable) do
force:Destroy()
end
end)
end)
local function check(room)
local Assets = room:WaitForChild("Assets",2)
if Assets then
for _,obj in ipairs(Assets:GetChildren()) do
if string.match(obj.Name,"Painting") or string.match(obj.Name,"painting") then
for _,instance in ipairs(obj:GetDescendants()) do
if instance:IsA("BasePart") or instance:IsA("Part") or instance:IsA("MeshPart") then
instance.CanTouch = true
end
end
end
end
end
end
local addconnect
addconnect = workspace.CurrentRooms.ChildAdded:Connect(function(room)
check(room)
end)
for i,v in pairs(workspace.CurrentRooms:GetChildren()) do
check(v)
end
task.spawn(function()
repeat task.wait() until rocketLauncher == nil or not (rocketLauncher:IsDescendantOf(player.Character) or rocketLauncher:IsDescendantOf(player.Backpack))
addconnect:Disconnect()
Rocket:Destroy()
end)