Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why do my explosions happen at 0,0,0?

Asked by 3 years ago

I am trying to make a GUI button that makes users explode when clicked. The explosions do not happen at the position of the player, but at 0,0,0. How do I fix this?

Here is the local script within the GUI button:

local RS = game.ReplicatedStorage
local explosionEvent = RS.Explosion

script.Parent.MouseButton1Click:Connect(function ()
    local plrPosition = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position
    explosionEvent:FireServer(plrPosition)
end)

Here is the server script within ServerScriptService:

local RS = game.ReplicatedStorage

local explosionEvent = RS.Explosion
explosionEvent.OnServerEvent:Connect(function(player, plrPosition)
    print(plrPosition)
    local explosion = Instance.new("Explosion", game.Workspace)
    explosion.Position = Vector3.new(plrPosition)
    explosion.BlastRadius = 10
    explosion.DestroyJointRadiusPercent = 0
end)

1 answer

Log in to vote
1
Answered by 3 years ago

You dont need the Vector3.new() because plrPosition already has a Vector3 value.

explosion.Position = plrPosition
Ad

Answer this question