Grenade goes backwards

The title says it all

local Throw = script.Parent:WaitForChild("Throw")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SmokeGrenade = ReplicatedStorage:WaitForChild("SmokeGrenade")

Throw.OnServerEvent:Connect(function(player, Pos)
	
	local Char = player.Character or player.CharacterAdded:Wait()
	
	local HRP = Char:FindFirstChild("HumanoidRootPart")
	
	if HRP then
		
		local Cloned_SmokeGrenade = SmokeGrenade:Clone()
		Cloned_SmokeGrenade.Parent = game.Workspace

		Cloned_SmokeGrenade.CFrame = CFrame.new(HRP.Position + Vector3.new(0,1,3))
		
		Cloned_SmokeGrenade.Velocity = Pos
		
		wait(1)
		
		Cloned_SmokeGrenade.Touched:Connect(function()
			
			local TempPart = Instance.new("Part")
			TempPart.Parent = game.Workspace
			
			local Smoke = Instance.new("Smoke")
			Smoke.Parent = TempPart
			
			Smoke.Color = Color3.fromRGB(213,213,213)
			Smoke.Size = 45
			
			wait(12)
			
			TempPart:Destroy()
			
		end)
		
		Cloned_SmokeGrenade:Destroy()
		
	end
	
end)

NOTE: “Pos” means Mouse.Hit.Position

1 Like

Try doing this instead

local Throw = script.Parent:WaitForChild("Throw")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SmokeGrenade = ReplicatedStorage:WaitForChild("SmokeGrenade")

Throw.OnServerEvent:Connect(function(player, Pos)
	local Char = player.Character or player.CharacterAdded:Wait()
	local HRP = Char:FindFirstChild("HumanoidRootPart")
	
	if HRP then
		local Cloned_SmokeGrenade = SmokeGrenade:Clone()
		Cloned_SmokeGrenade.Parent = game.Workspace
		Cloned_SmokeGrenade.CFrame = CFrame.new(HRP.Position + Vector3.new(0,1,3), Pos)
		Cloned_SmokeGrenade.Velocity = Cloned_SmokeGrenade.LookVector * 100 --Multiply this by how fast you want the grenade to travel
		wait(1)
		
		Cloned_SmokeGrenade.Touched:Connect(function()
			local TempPart = Instance.new("Part")
			TempPart.Parent = game.Workspace
			local Smoke = Instance.new("Smoke")
			Smoke.Parent = TempPart
			Smoke.Color = Color3.fromRGB(213,213,213)
			Smoke.Size = 45
			wait(12)
			TempPart:Destroy()
		end)
		Cloned_SmokeGrenade:Destroy()
	end
end)

It works but not how I want it to, it only goes back and down

How are you wanting to replicate the Grenade’s physics then? Like what an actual grenade is supposed to do?

just throw watch this video if you need more info (timestamp: 8:22)

Just increase the Velocity of the 100 number if you want it to travel more forwards?

wdym velocity 100? its using mouse.hit.position

I mean this, change the 100 number to whatever you want to determine how far you want the grenade to travel

ik but then the grenade will go back since idk were the lookvector is

You should be using LookVector.Unit

Alright to get a velocity you need two things.

  • speed
  • direction

To get a direction you can do
local direction = (Position1 - Position2).Unit
That will give you a direction from position2 to position1

Second speed which is pretty easy
local speed = 5--Any number will do
Then to get velocity
local velocity = speed * direction

If you want the grenade to go up a bit simply add it on to the equation
local velocity = (speed * direction) + Vector3.new(0,10,0)--Depending on how high you want it

Of course use AssemblyLInearVelocity instead of Velocity bc it is depracated

whats lookvector.unit i only used lookvector.cframe

What difference would it make? I know it sets the value as 1 or something, but I’m not sure what purpose you’d use it on

local Throw = script.Parent:WaitForChild("Throw")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SmokeGrenade = ReplicatedStorage:WaitForChild("SmokeGrenade")

Throw.OnServerEvent:Connect(function(player, Pos)
	local Char = player.Character or player.CharacterAdded:Wait()
	local HRP = Char:FindFirstChild("HumanoidRootPart")
	
	if HRP then
		local Cloned_SmokeGrenade = SmokeGrenade:Clone()
		Cloned_SmokeGrenade.Parent = game.Workspace
		Cloned_SmokeGrenade.CFrame = CFrame.new(HRP.Position + Vector3.new(0,1,3), Pos)
		Cloned_SmokeGrenade.Velocity = Cloned_SmokeGrenade.LookVector.Unit * 100 --Multiply this by how fast you want the grenade to travel
		wait(1)
		
		Cloned_SmokeGrenade.Touched:Connect(function()
			local TempPart = Instance.new("Part")
			TempPart.Parent = game.Workspace
			local Smoke = Instance.new("Smoke")
			Smoke.Parent = TempPart
			Smoke.Color = Color3.fromRGB(213,213,213)
			Smoke.Size = 45
			wait(12)
			TempPart:Destroy()
		end)
		Cloned_SmokeGrenade:Destroy()
	end
end)

Other way, CFrame.LookVector

You need it to make sure that the sped stays the same. It is complicated and you can look it up, just please use it. Without it it could be vulnerable to unwanted problems with speed and exploiters changing bullet speed.

what does the .unit do? is it basically magnitude

Why are you asking me? All I know is that it’s used for directional Vectors (For some reason) & start as a Value with 1

do i need to modify the AssemblyLInearVelocity

image

I’m dumb I forgot the CFrame

local Throw = script.Parent:WaitForChild("Throw")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SmokeGrenade = ReplicatedStorage:WaitForChild("SmokeGrenade")

Throw.OnServerEvent:Connect(function(player, Pos)
	local Char = player.Character or player.CharacterAdded:Wait()
	local HRP = Char:FindFirstChild("HumanoidRootPart")
	
	if HRP then
		local Cloned_SmokeGrenade = SmokeGrenade:Clone()
		Cloned_SmokeGrenade.Parent = game.Workspace
		Cloned_SmokeGrenade.CFrame = CFrame.new(HRP.Position + Vector3.new(0,1,3), Pos)
		Cloned_SmokeGrenade.Velocity = Cloned_SmokeGrenade.CFrame.LookVector.Unit * 100 --Multiply this by how fast you want the grenade to travel
		wait(1)
		
		Cloned_SmokeGrenade.Touched:Connect(function()
			local TempPart = Instance.new("Part")
			TempPart.Parent = game.Workspace
			local Smoke = Instance.new("Smoke")
			Smoke.Parent = TempPart
			Smoke.Color = Color3.fromRGB(213,213,213)
			Smoke.Size = 45
			wait(12)
			TempPart:Destroy()
		end)
		Cloned_SmokeGrenade:Destroy()
	end
end)

the only problem is that it falls