Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my Magic Explosion script not working? I'm getting no errors and It should be working!!

I'm trying to make a tool where when you activate it, it should shoot a projectile and then if that projectile hits a player it will explode and damage the player. It is still wip but for some reason the part isn't spawning like how I wanted to in the script, help!!

Local Script:

local Tool = script.Parent.Parent.GhostDash

Tool.Activated:Connect(function()
	script.Parent.RemoteEvent:FireServer()
end)

Script (main):

local combatModule = require(game.ReplicatedStorage.Effects)

local moveoneenabled = true

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://6736788633"

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
	print("beans")

	local grenade = Instance.new("Part")
	grenade.Shape = Enum.PartType.Ball
	grenade.Position = player.Character.HumanoidRootPart.Position
	grenade.CanCollide = false
	grenade.Anchored = true
	grenade.Parent = game.Workspace
end)

I don't seem to be getting any errors, and the part is not appearing.. bit of help? :)

1 comment

0

does it print beans?

1 answer

You need to use the Roblox Built-In explosion function. It is very easy, just replace your main script with the given:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
	print("beans")

 	local grenade = Instance.new("Part")
 	grenade.Shape = Enum.PartType.Ball
 	grenade.Position = player.Character.HumanoidRootPart.Position
 	grenade.CanCollide = false
	grenade.Anchored = true
	grenade.Parent = game.Workspace

	local Explosion = Instance.new("Explosion")
	Explosion.BlastRadius = 100 -- The power of the explosion
	Explosion.Position = grenade.Position
	Explosion.Parent = game.Workspace
end)

1 comment

0

^ This is a great solution. But however, if you would like to make some changes, the best choices are to make the part transparent in the script, and destroying the part when the explosion is finished (to prevent lag)

This discussion is preserved as it was. New answers, comments, and votes are closed.