How do i make explosion when player touch a part

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I must make telekinesis power and i want to make a power that propel player and make an explosion when it touch a wall
  2. What is the issue? Include screenshots / videos if possible!
    I have a part in replicated storage with particule emmiter it’s my explosion and i want clone it change the position to the ennemy humanoid and set parent to workspace
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i try to add debounce
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    it’s in a server script in all part in workspace
local Debounce = true
local CoolDown = 1

script.Parent.Touched:Connect(function(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if Humanoid then
		local CanBeExplode = Humanoid:FindFirstChild("CanBeExplode")
		if CanBeExplode  then
			if CanBeExplode.Value == true then
				if Debounce == true then
					Debounce = false
					print("Explode")
					local Explosion = game.ReplicatedStorage.Assets.Prue_Assets.Explosion:Clone()
					Explosion.Position = hit.Parent:FindFirstChild("HumanoidRootPart")
					Explosion.Parent = game.Workspace
					CanBeExplode.Value = false
					wait(CoolDown)
					Debounce = true
				end
			end
		end
	end
end)

CanBeExplode it’s a bool value in all player set to false and server change it when player is propel i already make propel system

i don’t have any error it only works once

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Disregard, read your debounce system wrong.

Could I possibly see an example of your CanBeExplode Boolvalue system? I think the issue might lie there.

–In a local script:

local function ButtonHandler(action, inputState)
	if action == "TelePunching" then
		local target = mouse.Target
		if target.Parent:IsA("Model") then
			local Animator = Character.Humanoid.Animator
			local TelekinesisPunch = Animator:LoadAnimation(TelePunchAnimation)
			TelekinesisPunch:Play()
		end
		wait(0.8)
		PowerEvent:FireServer(action, inputState, target)
		
	elseif action == "ExplosivePunching" then
		local Animator = Character.Humanoid.Animator
		local TelekinesisPunch = Animator:LoadAnimation(TeleExplosivePunchAnimation)
		local target = mouse.Target
		TelekinesisPunch:Play()
		wait(0.8)
		PowerEvent:FireServer(action, inputState ,target ,Character.HumanoidRootPart)
	end
end

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	if input.KeyCode == Enum.KeyCode.H then
		if CanTeleExplosivePunch == true then
			CanTeleExplosivePunch = false
			ButtonHandler("ExplosivePunching", input.UserInputState.Name)
			wait(ExplosiveTelePunchCooldDown)
			CanTeleExplosivePunch = true
		end
	end
end)

–In a server script:

if Power == "ExplosivePunching" then
		if State == "Begin" then
			for i, v in	 pairs(game.Workspace:GetChildren()) do
				if v:IsA("Model") then
					if (ClientHRP.Position - v:FindFirstChild("HumanoidRootPart").Position).Magnitude <= 25 then
						if v ~= game.Workspace[client.Name] then
							local physiscs = 3

							local KnockBack = Instance.new("BodyVelocity")

							KnockBack.Parent = v:FindFirstChild("HumanoidRootPart")
							v:FindFirstChild("Humanoid").CanBeExplode.Value = true

							KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
							KnockBack.Velocity = ClientHRP.CFrame.LookVector * Speed

The most I can infer here is that I’m either oblivious, or there’s likely some type of error within your ExplosivePunching server-side script or your client-side script. I’m not well equipped to look at frameworks concerning physics, so I can’t really help you here, my condolences. I’d recommend to just review your client-side and server-side by perhaps putting some prints here and there, and see where the problem lies.

I have just make an error and i don’t put .Position after Humanoid

1 Like