Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Trying to make a shovel that digs out terrain?

Asked by 3 days ago
Edited 3 days ago

I'm attempting to make a game based on the Eastern Front, so I'm making a shovel that will allow you to dig out trenches, foxholes, ditches, etc. However, my code is not working.

The explosion just keeps inserting at the center of the map, and nowhere else.

Please Help!

Client Script:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local mouseHit = mouse.Hit.p

script.Parent.Activated:Connect(function()
    game.ReplicatedStorage.DigTerrain:FireServer(mouseHit)
end)

Server Script:

--/ Explosion Variables \--
local ex = Instance.new("Explosion")
ex.ExplosionType = Enum.ExplosionType.Craters
ex.BlastPressure = 100
ex.DestroyJointRadiusPercent = 0
ex.Visible = false
ex.BlastRadius = 10
local debounce = false

--/ Main Function \--
game.ReplicatedStorage.DigTerrain.OnServerEvent:Connect(function(plr, mouseTarget)
    if debounce == false then
        debounce = true
        local exClone = ex:Clone()

        exClone.Position = mouseTarget
        exClone.Parent = workspace
        wait(0.5)
        debounce = false
    end
end)
0
Yeah i had this idea once. I wanted to do this once but i think i see the problem here, I dont think that you should use mouseHit.p as you are passing a Vector3 and not a mouse. kepiblop 36 — 3d
0
And should probably put a player variable beside mouseHit on the server script on line 11 kepiblop 36 — 3d
0
Ok, Thanks! Louscascicly 0 — 3d
0
your welcome! And also i kind of got a bit inspiration from this so thank you too! kepiblop 36 — 3d
View all comments (3 more)
0
did it work? The pos variable shouldn't be there and also uhh localplayer cannot be called on server script s Andput it like this :Connect(function(player,mouseTarget) and you should also just use mouseTarget instead of wrapping it in a vector3 like this exClone.Position = mouseTarget kepiblop 36 — 3d
0
It still only inserts at the center of the map. I did everything you said to do. Louscascicly 0 — 3d
0
Nvm, i fixed it, thank you! Louscascicly 0 — 2d

Answer this question