So I made this script and when I activate it, the part spawns where i want yes. But it spawns facing in the same direction. I want it to face the direction my torso is facing. Please help, you may add on to my script :)
player = game.Players.LocalPlayer
mouse = player:GetMouse()
mouse.Move:connect(function()
local target = mouse.Target
if target.Name == "Grass" then
print("Spawning sand...")
else
print("You can only use sand on grass!")
end
end)
mouse.KeyDown:connect(function(key)
local target = mouse.Target
if key == "c" and target.Name == "Grass" then
local sand = Instance.new("Part", game.Workspace)
sand.Name = "Sand"
sand.Anchored = true
sand.BrickColor = BrickColor.new("Pastel brown")
sand.Material = "Sand"
sand.Size = Vector3.new(8, 10, 2)
-- Surfaces:
sand.BackSurface = "Smooth"
sand.BottomSurface = "Smooth"
sand.FrontSurface = "Smooth"
sand.LeftSurface = "Smooth"
sand.RightSurface = "Smooth"
sand.TopSurface = "Smooth"
-- Position:
sand.CFrame = CFrame.new(mouse.Hit.p) + Vector3.new(0, 4.8, 0)
end
end)

2 comments
Please help, this is really important!
Remember that all surfaces except the top and bottom are smooth by default. You could get rid of at least four lines that way.