Mimicking an explosion

I’m just trying to make it so the closer a player is to a this part that they click, the further they will be shot out relative to their look vector, mimicking an explosion. Results have not been promising, i sure this is a very easy fix that I am not seeing. Thanks.

event.OnClientEvent:Connect(function()
	

	local rootpart = player.Character:FindFirstChild("HumanoidRootPart")
		player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Flying)
			--[[local impulse = Vector3.new(5000, 2000, 0)

			rootpart:ApplyImpulse(impulse)]]
			
			
	local look = CFrame.new(root.Position, blastcenter.Position)
	root.AssemblyLinearVelocity = -look.LookVector * 1000 / ((blastcenter.Position) - (root.Position))
			print(root.AssemblyLinearVelocity)
end)

try this

event.OnClientEvent:Connect(function()
	local rootpart = player.Character:FindFirstChild("HumanoidRootPart")
	player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Flying)
	
	local look = CFrame.new(root.Position, blastcenter.Position)
	local dist = (blastcenter.Position - root.Position).Magnitude
	local max_vel = 100
	root.AssemblyLinearVelocity = -look.LookVector * math.max((max_vel - dist^2), 0)
	
	print(root.AssemblyLinearVelocity)
end)

x_m = max velocity
x_r = explosion radius
d = radius multiplier (not sure what to call this)


In code:

event.OnClientEvent:Connect(function()
	local rootpart = player.Character:FindFirstChild("HumanoidRootPart")
	player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Flying)
	
	local look = CFrame.new(root.Position, blastcenter.Position)
	local dist = (blastcenter.Position - root.Position).Magnitude
	local max_vel = 100
	local radius = 5
	local damp = radius^2/max_vel
	local velocity = (max_vel - dist^2/damp)
	if velocity > 0 then
		root.AssemblyLinearVelocity = -look.LookVector * velocity
	end
	
	print(root.AssemblyLinearVelocity)
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.