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)

7 comments

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.

0

And should probably put a player variable beside mouseHit on the server script on line 11

0

Ok, Thanks!

0

your welcome! And also i kind of got a bit inspiration from this so thank you too!

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

0

It still only inserts at the center of the map. I did everything you said to do.

0

Nvm, i fixed it, thank you!