SHOW:
|
|
- or go back to the newest paste.
1 | function sandbox(var,func) | |
2 | local env = getfenv(func) | |
3 | local newenv = setmetatable({},{ | |
4 | __index = function(self,k) | |
5 | if k=="script" then | |
6 | return var | |
7 | else | |
8 | return env[k] | |
9 | end | |
10 | end, | |
11 | }) | |
12 | setfenv(func,newenv) | |
13 | return func | |
14 | end | |
15 | cors = {} | |
16 | mas = Instance.new("Model",game:GetService("Lighting")) | |
17 | Tool0 = Instance.new("Tool") | |
18 | Part1 = Instance.new("Part") | |
19 | SpecialMesh2 = Instance.new("SpecialMesh") | |
20 | Sound3 = Instance.new("Sound") | |
21 | Sound4 = Instance.new("Sound") | |
22 | Animation5 = Instance.new("Animation") | |
23 | Configuration6 = Instance.new("Configuration") | |
24 | NumberValue7 = Instance.new("NumberValue") | |
25 | NumberValue8 = Instance.new("NumberValue") | |
26 | NumberValue9 = Instance.new("NumberValue") | |
27 | BoolValue10 = Instance.new("BoolValue") | |
28 | NumberValue11 = Instance.new("NumberValue") | |
29 | LocalScript12 = Instance.new("LocalScript") | |
30 | RemoteEvent13 = Instance.new("RemoteEvent") | |
31 | Script14 = Instance.new("Script") | |
32 | Tool0.Name = "Grenade" | |
33 | Tool0.Parent = mas | |
34 | Tool0.TextureId = "http://www.roblox.com/asset/?id=200845119" | |
35 | Tool0.Grip = CFrame.new(0, 0, 0.200000003, 0.894391418, 0.00999950059, -0.447173357, -0.00894391444, 0.999949992, 0.0044717337, 0.447195709, 0, 0.894436121) | |
36 | Tool0.GripForward = Vector3.new(0.447173357, -0.0044717337, -0.894436121) | |
37 | Tool0.GripPos = Vector3.new(0, 0, 0.200000003) | |
38 | Tool0.GripRight = Vector3.new(0.894391418, -0.00894391444, 0.447195709) | |
39 | Tool0.GripUp = Vector3.new(0.00999950059, 0.999949992, 0) | |
40 | Tool0.ToolTip = "KABOOM" | |
41 | Part1.Name = "Handle" | |
42 | Part1.Parent = Tool0 | |
43 | Part1.CFrame = CFrame.new(-11.5000105, 104.200005, 55.0750046, 0, 0, 1, 0, 1, -0, -1, 0, 0) | |
44 | Part1.Orientation = Vector3.new(0, 90, 0) | |
45 | Part1.Position = Vector3.new(-11.5000105, 104.200005, 55.0750046) | |
46 | Part1.Rotation = Vector3.new(0, 90, 0) | |
47 | Part1.Color = Color3.new(0.152941, 0.27451, 0.176471) | |
48 | Part1.Size = Vector3.new(0.800000131, 0.920000255, 0.799998164) | |
49 | Part1.BottomSurface = Enum.SurfaceType.Smooth | |
50 | Part1.BrickColor = BrickColor.new("Earth green") | |
51 | Part1.CanCollide = false | |
52 | Part1.Locked = true | |
53 | Part1.TopSurface = Enum.SurfaceType.Smooth | |
54 | Part1.brickColor = BrickColor.new("Earth green") | |
55 | Part1.FormFactor = Enum.FormFactor.Custom | |
56 | Part1.formFactor = Enum.FormFactor.Custom | |
57 | SpecialMesh2.Parent = Part1 | |
58 | SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=166887416" | |
59 | SpecialMesh2.Scale = Vector3.new(1.29999995, 1.5, 1.29999995) | |
60 | SpecialMesh2.MeshType = Enum.MeshType.FileMesh | |
61 | Sound3.Name = "Pin" | |
62 | Sound3.Parent = Part1 | |
63 | Sound3.SoundId = "http://www.roblox.com/asset?id=168184001" | |
64 | Sound3.Volume = 1 | |
65 | Sound4.Name = "Boom" | |
66 | Sound4.Parent = Part1 | |
67 | Sound4.PlayOnRemove = true | |
68 | Sound4.SoundId = "rbxasset://sounds/collide.wav" | |
69 | Sound4.Volume = 1 | |
70 | Animation5.Name = "ThrowAnimation" | |
71 | Animation5.Parent = Tool0 | |
72 | Animation5.AnimationId = "http://www.roblox.com/Asset?ID=168160500" | |
73 | Configuration6.Name = "Configurations" | |
74 | Configuration6.Parent = Tool0 | |
75 | NumberValue7.Name = "Cooldown" | |
76 | NumberValue7.Parent = Configuration6 | |
77 | NumberValue7.Value = 3 | |
78 | NumberValue8.Name = "GrenadeVelocity" | |
79 | NumberValue8.Parent = Configuration6 | |
80 | NumberValue8.Value = 100 | |
81 | NumberValue9.Name = "FuseTime" | |
82 | NumberValue9.Parent = Configuration6 | |
83 | NumberValue9.Value = 5 | |
84 | BoolValue10.Name = "ExplodeOnTouch" | |
85 | BoolValue10.Parent = Configuration6 | |
86 | BoolValue10.Value = true | |
87 | NumberValue11.Name = "ExplosionRadius" | |
88 | NumberValue11.Parent = Configuration6 | |
89 | NumberValue11.Value = 5 | |
90 | LocalScript12.Name = "ClientScript" | |
91 | LocalScript12.Parent = Tool0 | |
92 | table.insert(cors,sandbox(LocalScript12,function() | |
93 | local player = game.Players.LocalPlayer | |
94 | local mouse = player:GetMouse() | |
95 | local tool = script.Parent | |
96 | local config = tool:WaitForChild("Configurations") | |
97 | ||
98 | local canThrow = true | |
99 | ||
100 | tool.Equipped:connect(function() | |
101 | mouse.Icon = "rbxasset://textures/GunCursor.png" | |
102 | end) | |
103 | ||
104 | tool.Unequipped:connect(function() | |
105 | mouse.Icon = "" | |
106 | end) | |
107 | ||
108 | tool.Activated:connect(function() | |
109 | if canThrow then | |
110 | canThrow = false | |
111 | local throwAnimation = player.Character.Humanoid:LoadAnimation(tool.ThrowAnimation) | |
112 | throwAnimation:Play() | |
113 | throwAnimation.KeyframeReached:connect(function(keyframe) | |
114 | if keyframe == "tick" then | |
115 | tool.Handle.Pin:Play() | |
116 | elseif keyframe == "throw" then | |
117 | tool.Throw:FireServer(mouse.Hit.p) | |
118 | throwAnimation:Stop() | |
119 | mouse.Icon = "rbxasset://textures/GunWaitCursor.png" | |
120 | end | |
121 | end) | |
122 | wait(config.Cooldown.Value) | |
123 | mouse.Icon = "rbxasset://textures/GunCursor.png" | |
124 | canThrow = true | |
125 | end | |
126 | end) | |
127 | end)) | |
128 | RemoteEvent13.Name = "Throw" | |
129 | RemoteEvent13.Parent = Tool0 | |
130 | Script14.Name = "ServerScript" | |
131 | Script14.Parent = Tool0 | |
132 | table.insert(cors,sandbox(Script14,function() | |
133 | local tool = script.Parent | |
134 | local config = tool:WaitForChild("Configurations") | |
135 | ||
136 | function AngleOfReach(distance, altitude, velocity) | |
137 | local theta = math.atan((velocity^2 + math.sqrt(velocity^4 -196.2*(196.2*distance^2 + 2*altitude*velocity^2)))/(196.2*distance)) | |
138 | if theta ~= theta then | |
139 | theta = math.pi/4 | |
140 | end | |
141 | return(theta) | |
142 | end | |
143 | ||
144 | function Explode(part) | |
145 | local explosion = Instance.new("Explosion", workspace) | |
146 | explosion.Position = part.Position | |
147 | explosion.BlastRadius = config.ExplosionRadius.Value | |
148 | part:Destroy() | |
149 | end | |
150 | ||
151 | script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition) | |
152 | local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z) | |
153 | local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z) | |
154 | local distance = (handlePos - mousePos).magnitude | |
155 | local altitude = mousePosition.Y - tool.Handle.Position.Y | |
156 | local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value) | |
157 | ||
158 | tool.Handle.Transparency = 1 | |
159 | local grenade = tool.Handle:Clone() | |
160 | grenade.Parent = workspace | |
161 | grenade.Transparency = 0 | |
162 | grenade.CanCollide = true | |
163 | grenade.CFrame = tool.Handle.CFrame | |
164 | grenade.Velocity = (CFrame.new(grenade.Position, Vector3.new(mousePosition.X, grenade.Position.Y, mousePosition.Z)) * CFrame.Angles(angle, 0, 0)).lookVector * config.GrenadeVelocity.Value -- Throwing 'n stuff, it probably didn't need to be this long | |
165 | spawn(function() | |
166 | if config.ExplodeOnTouch.Value then | |
167 | grenade.Touched:connect(function(hit) | |
168 | if hit.Parent ~= tool.Parent and hit.CanCollide then | |
169 | Explode(grenade) | |
170 | end | |
171 | end) | |
172 | else | |
173 | ||
174 | wait(config.FuseTime.Value) | |
175 | Explode(grenade) | |
176 | end | |
177 | end) | |
178 | wait(config.Cooldown.Value) | |
179 | tool.Handle.Transparency = 0 | |
180 | end) | |
181 | end)) | |
182 | for i,v in pairs(mas:GetChildren()) do | |
183 | v.Parent = workspace | |
184 | pcall(function() v:MakeJoints() end) | |
185 | end | |
186 | mas:Destroy() | |
187 | for i,v in pairs(cors) do | |
188 | spawn(function() | |
189 | pcall(v) | |
190 | end) | |
191 | end | |
192 | - | Tool0.Parent = game.Players.Webcat70.Backpack |
192 | + | Tool0.Parent = game.Players.lafur2.Backpack |