I am trying to detect if the mouse.Target is "Top" then, I want the part to be placed on top.
Local Script
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local grass = script.Blocks.GrassBlock
local grassClone = grass:Clone()
grassClone.Parent = game.Workspace
local grid = 3
local finalPos = CFrame.new()
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
mouse.Button1Down:Connect(function()
grassClone.PrimaryPart = grassClone.Hitbox
grassClone.PrimaryPart.BrickColor = BrickColor.White()
grassClone.PrimaryPart.Transparency = 0.9
local floorX = math.floor(mouse.Hit.X / grid + 0.5) * grid
local floorZ = math.floor(mouse.Hit.Z / grid + 0.5) * grid
finalPos = CFrame.new(floorX, 3, floorZ)
event:FireServer("GrassBlock", finalPos)
end)
Server Script
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local blocks = game.StarterGui.PlacementNoMouse.Blocks
local function test(player, block, pos)
p = blocks:FindFirstChild(block):Clone() -- leave this var. without local
p.Parent = game.Workspace
p:SetPrimaryPartCFrame(pos)
p.PrimaryPart.Name = "Destroyable"
local part = Instance.new("Part", p)
part.Size = Vector3.new(3, 0.5, 3)
part.Position = p.PrimaryPart.Position + Vector3.new(0, 1.5, 0)
part.Anchored = true
part.Name = "Top"
end
event.OnServerEvent:Connect(test)
Thanks for the Help!
