Explosions on playerPosition from tool

I want to make it so that when I click it creates and puts a explosion on the player. I already got the first half done. I just don’t know how to set the explosions position to the players. If I’m missing something here it would be nice if you let me know. Like if there was something obvious that I missed or something.

4 Likes

Could you show us your script so far?

1 Like

Explosions have a .Position property. Simply set the .Position of the explosion to the place you want to explode. For example,

explosion.Position = workspace.Player.Head.Position

I am not totally sure about your whole issue but I have got a script that will put explosion in the players character if you click on the player with the tool equipped
local script :


server script :

this is not finished though it works
Reply if you don’t understand the script and I am sure I will help :slight_smile:

Sorry It took me a while to notice! The plan for this script was that when the event fired from the local script the explosion would be created and placed on the players position. You don’t need to mind the comments.

Sorry I don’t know if this script really fits what I’m looking for exactly because I’m not using or planning on using raycasts for this! Thanks for the input however! Sorry for taking up your time!

Yes, if that is your plan then you can use my script but in case you don’t understand a line of code just tell me to explain it
for sounds, you can add them when OnServerEvent is triggered

I am sorry couldnt see this alright no problem , actually I thought you wanted so that when you clicked on a player with the tool equipped the explosion should occur on that players character
In this case you can simply just do this :

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    local explosion = Instance.new("Explosion")
    -- Define explosion however you are liking it 
    
    
    explosion.Position = player.Character.HumanoidRootPart.Position
    explosion.Parent = player.Character.HumanoidRootPart
end)

As the tool is activated this should work , if this doesn’t work just inform

Whoever fires the “FirePing” remote is the one that needs the explosion correct? In that case, use the player argument that is passed from .OnServerEvent()

script.Parent.FirePing.OnServerEvent:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local rootPart = humanoid.RootPart
    -- explosion
    explosion.Position = rootPart.Position
end)

explosion.Position = player.Character.HumanoidRootPart.Position

Yours and magical’s posts are really similar so I thought the outcome was the same but I guess it wasn’t. Don’t worry the code you’ve typed is pretty simple and honestly I’m embarrassed that I didn’t remember that I could insert player into the function. Thanks for the assistance. I tend to overlook things because they’re too simple.