Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Sound3 = Instance.new("Sound")
- Sound4 = Instance.new("Sound")
- Animation5 = Instance.new("Animation")
- Configuration6 = Instance.new("Configuration")
- NumberValue7 = Instance.new("NumberValue")
- NumberValue8 = Instance.new("NumberValue")
- NumberValue9 = Instance.new("NumberValue")
- BoolValue10 = Instance.new("BoolValue")
- NumberValue11 = Instance.new("NumberValue")
- LocalScript12 = Instance.new("LocalScript")
- RemoteEvent13 = Instance.new("RemoteEvent")
- Script14 = Instance.new("Script")
- Tool0.Name = "Grenade"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=200845119"
- 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)
- Tool0.GripForward = Vector3.new(0.447173357, -0.0044717337, -0.894436121)
- Tool0.GripPos = Vector3.new(0, 0, 0.200000003)
- Tool0.GripRight = Vector3.new(0.894391418, -0.00894391444, 0.447195709)
- Tool0.GripUp = Vector3.new(0.00999950059, 0.999949992, 0)
- Tool0.ToolTip = "KABOOM"
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.CFrame = CFrame.new(-11.5000105, 104.200005, 55.0750046, 0, 0, 1, 0, 1, -0, -1, 0, 0)
- Part1.Orientation = Vector3.new(0, 90, 0)
- Part1.Position = Vector3.new(-11.5000105, 104.200005, 55.0750046)
- Part1.Rotation = Vector3.new(0, 90, 0)
- Part1.Color = Color3.new(0.152941, 0.27451, 0.176471)
- Part1.Size = Vector3.new(0.800000131, 0.920000255, 0.799998164)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.BrickColor = BrickColor.new("Earth green")
- Part1.CanCollide = false
- Part1.Locked = true
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.brickColor = BrickColor.new("Earth green")
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.formFactor = Enum.FormFactor.Custom
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=166887416"
- SpecialMesh2.Scale = Vector3.new(1.29999995, 1.5, 1.29999995)
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- Sound3.Name = "Pin"
- Sound3.Parent = Part1
- Sound3.SoundId = "http://www.roblox.com/asset?id=168184001"
- Sound3.Volume = 1
- Sound4.Name = "Boom"
- Sound4.Parent = Part1
- Sound4.PlayOnRemove = true
- Sound4.SoundId = "rbxasset://sounds/collide.wav"
- Sound4.Volume = 1
- Animation5.Name = "ThrowAnimation"
- Animation5.Parent = Tool0
- Animation5.AnimationId = "http://www.roblox.com/Asset?ID=168160500"
- Configuration6.Name = "Configurations"
- Configuration6.Parent = Tool0
- NumberValue7.Name = "Cooldown"
- NumberValue7.Parent = Configuration6
- NumberValue7.Value = 3
- NumberValue8.Name = "GrenadeVelocity"
- NumberValue8.Parent = Configuration6
- NumberValue8.Value = 100
- NumberValue9.Name = "FuseTime"
- NumberValue9.Parent = Configuration6
- NumberValue9.Value = 5
- BoolValue10.Name = "ExplodeOnTouch"
- BoolValue10.Parent = Configuration6
- BoolValue10.Value = true
- NumberValue11.Name = "ExplosionRadius"
- NumberValue11.Parent = Configuration6
- NumberValue11.Value = 5
- LocalScript12.Name = "ClientScript"
- LocalScript12.Parent = Tool0
- table.insert(cors,sandbox(LocalScript12,function()
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local tool = script.Parent
- local config = tool:WaitForChild("Configurations")
- local canThrow = true
- tool.Equipped:connect(function()
- mouse.Icon = "rbxasset://textures/GunCursor.png"
- end)
- tool.Unequipped:connect(function()
- mouse.Icon = ""
- end)
- tool.Activated:connect(function()
- if canThrow then
- canThrow = false
- local throwAnimation = player.Character.Humanoid:LoadAnimation(tool.ThrowAnimation)
- throwAnimation:Play()
- throwAnimation.KeyframeReached:connect(function(keyframe)
- if keyframe == "tick" then
- tool.Handle.Pin:Play()
- elseif keyframe == "throw" then
- tool.Throw:FireServer(mouse.Hit.p)
- throwAnimation:Stop()
- mouse.Icon = "rbxasset://textures/GunWaitCursor.png"
- end
- end)
- wait(config.Cooldown.Value)
- mouse.Icon = "rbxasset://textures/GunCursor.png"
- canThrow = true
- end
- end)
- end))
- RemoteEvent13.Name = "Throw"
- RemoteEvent13.Parent = Tool0
- Script14.Name = "ServerScript"
- Script14.Parent = Tool0
- table.insert(cors,sandbox(Script14,function()
- local tool = script.Parent
- local config = tool:WaitForChild("Configurations")
- function AngleOfReach(distance, altitude, velocity)
- local theta = math.atan((velocity^2 + math.sqrt(velocity^4 -196.2*(196.2*distance^2 + 2*altitude*velocity^2)))/(196.2*distance))
- if theta ~= theta then
- theta = math.pi/4
- end
- return(theta)
- end
- function Explode(part)
- local explosion = Instance.new("Explosion", workspace)
- explosion.Position = part.Position
- explosion.BlastRadius = config.ExplosionRadius.Value
- part:Destroy()
- end
- script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition)
- local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z)
- local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z)
- local distance = (handlePos - mousePos).magnitude
- local altitude = mousePosition.Y - tool.Handle.Position.Y
- local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value)
- tool.Handle.Transparency = 1
- local grenade = tool.Handle:Clone()
- grenade.Parent = workspace
- grenade.Transparency = 0
- grenade.CanCollide = true
- grenade.CFrame = tool.Handle.CFrame
- 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
- spawn(function()
- if config.ExplodeOnTouch.Value then
- grenade.Touched:connect(function(hit)
- if hit.Parent ~= tool.Parent and hit.CanCollide then
- Explode(grenade)
- end
- end)
- else
- wait(config.FuseTime.Value)
- Explode(grenade)
- end
- end)
- wait(config.Cooldown.Value)
- tool.Handle.Transparency = 0
- end)
- end))
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = workspace
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
- Tool0.Parent = game.Players.lafur2.Backpack
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement