Quick actions

cmd+k|ctrl+k

Navigation

Languages

grenade

Snippet info

Language

Lua

Visibility

public

Author

zen

Created

2024-01-01T15:57:25.047961Z

Updated

2024-01-07T11:18:28.992544Z


local tool = Instance.new("Tool")
tool.Name = "Grenade"
tool.Grip = CFrame.new(0.038,-0.223,0.056) * CFrame.Angles(math.rad(-0.256),math.rad(-88.538),math.rad(-0.512))
tool.CanBeDropped = false
tool.RequiresHandle = true

local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(0.805,0.783,0.805)
handle.Anchored = false
handle.CanCollide = false
handle.CanTouch = false
handle.CanQuery = false
handle.Massless = true
handle.CustomPhysicalProperties = PhysicalProperties.new(0.7,0.3,1)
handle.Parent = tool

local mesh = Instance.new("SpecialMesh")
mesh.Parent = handle
mesh.MeshId = "rbxassetid://431532852"
mesh.TextureId = "rbxassetid://431532899"
mesh.Scale = Vector3.new(0.003,0.002,0.003)
mesh.Parent = handle

local throwEvent = Instance.new("RemoteEvent")
throwEvent.Name = "Event"
throwEvent.Parent = tool

tool.Parent = owner.Backpack


-- Server
--local character: Model = owner.Character or owner.CharacterAdded:Wait()
--local humanoid: Humanoid = character:WaitForChild("Humanoid")
--local handle: Part = tool:WaitForChild("Handle")
--local event: RemoteEvent = tool:WaitForChild("Event")

--event.OnServerEvent:Connect(function(player,direction: Vector3)
--	direction = direction.Unit
--	local sound = Instance.new("Sound")
--	sound.SoundId = "rbxassetid://5124872763"
--	sound.Volume = 5
--	sound.Parent = humanoid.RootPart
--	sound:Play()
--	local c
--	c = sound.Ended:Connect(function()
--		sound:Destroy()
--		c:Disconnect()
--	end)
--	local grenade: Part = handle:Clone()
--	grenade.CanCollide = true
--	grenade.CanQuery = true
--	grenade.CanTouch = true
--	grenade.Massless = false
--	grenade.Parent = workspace
--	grenade.CFrame = humanoid.RootPart.CFrame * CFrame.new(0,0,-2)
--	grenade:ApplyImpulse(direction * 25)

--	task.delay(2,function()
--		local explosion = Instance.new("Explosion")
--		explosion.Parent = workspace
--		explosion.Position = grenade.Position
--		grenade:Destroy()
--	end)
--end)

---- Client
--local character: Model = owner.Character or owner.CharacterAdded:Wait()
--local humanoid: Humanoid = character:WaitForChild("Humanoid")
--local mouse: Mouse = owner:GetMouse()
--local event: RemoteEvent = tool:WaitForChild("Event")

--tool.Activated:Connect(function()
--	event:FireServer((mouse.Hit.Position - humanoid.RootPart.Position).Unit)
--end)

NLS([==[
local tool = script.Parent
local character = owner.Character or owner.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local mouse = owner:GetMouse()
local event = tool:WaitForChild("Event")

tool.Activated:Connect(function()
	event:FireServer((mouse.Hit.Position - humanoid.RootPart.Position).Unit)
end)
]==],tool)

NS([==[
local tool = script.Parent
local character = owner.Character or owner.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local handle = tool:WaitForChild("Handle")
local event = tool:WaitForChild("Event")

event.OnServerEvent:Connect(function(player,direction: Vector3)
	direction = direction.Unit
	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://5124872763"
	sound.Volume = 5
	sound.Parent = humanoid.RootPart
	sound:Play()
	local c
	c = sound.Ended:Connect(function()
		sound:Destroy()
		c:Disconnect()
	end)
	local grenade = handle:Clone()
	grenade.CanCollide = true
	grenade.CanQuery = true
	grenade.CanTouch = true
	grenade.Massless = false
	grenade.Parent = workspace
	grenade.CFrame = humanoid.RootPart.CFrame * CFrame.new(0,0,-2)
	grenade:ApplyImpulse(direction * 30 + humanoid.RootPart.CFrame.UpVector * 15)

	task.delay(2,function()
		local explosion = Instance.new("Explosion")
		explosion.Parent = workspace
		explosion.Position = grenade.Position
		explosion.BlastPressure = 100
		explosion.BlastRadius = 20
		explosion.DestroyJointRadiusPercent = 0.9
		grenade:Destroy()
	end)
end)
]==],tool)
INFO