Make Part Spawn On Ground EveryTime

Local Script

		player.Mana.Value = player.Mana.Value - 0.05
		local Mousepos = Mouse.hit.p
		script.RemoteEvent:FireServer("Second", Mousepos)--Whatever function you would like to call
	end
end)

Script

		
		local NIceV = IceV:Clone()
		NIceV.Parent = game.Workspace
		game.Debris:AddItem(NIceV,3)
		
		local antiGravity1 = Instance.new("BodyForce")
		antiGravity1.Force = Vector3.new(0, workspace.Gravity * NIceV:GetMass(), 0)
		antiGravity1.Parent = NIceV
		
		NIceV.Position = Mousepos

Why I need help: I want the part to spawn at the Mouse position but I want it to spawn on the ground everytime. For example if a player point in the air then the part going to spawn in the air. Sometimes if a player point at the bottom it spawn under the ground.

Question: How would I make it y position the same all the time?

Change this line to:

local Mousepos = Vector3.new(Mouse.hit.p.X, 0, Mouse.hit.p.Z)

I haven’t tested this but it might work.

1 Like
local Mousepos = Mouse.hit.Position

Doing this is wrong since it will get Mouse Position in a Vector3 value completely

local MouseZ = Mouse.hit.Z
local MouseX = Mouse.hit.X
local MouseY = 0

And putting this in a Vector3 value like

ExamplePart.CFrame = 
Vector3.new(MouseX,0,MouseZ)

Will solve your problem!

Whell, Just do this:

Part.Position = mouse.hit.p

Why? Try this

local Mousepos = Vector3.new(MouseX,MouseY,MouseZ)

This script would change position of mouse and not work, Change the parts CFrame not Mouse’s also this guy wants part’s position to stay on ground so you would make Y = 0 in order to do this.

1 Like

So this?

local Mousepos = Vector3.new(MouseX,0,MouseZ)
1 Like

No, You would set part’s location not Mouse’s.

Part.CFrame = Vector3.new(MouseX,0,MouseZ)
1 Like
Ok lol test only

Maybe it works

No, MouseX and MouseZ is for a 2d GUI. try, Part.Position = Vector3.new(MousePos.X, 0, MousePos.Z)

1 Like

Yeah that worked even though I figured out by myself on my own. :smiley: