I've been trying to find out why on line 50 it won't check if where they place the object is on their plot. I have asked this question before and no one has answered. Please help if you can/
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local PlaceObject = game.ReplicatedStorage.BuildEvents.PlaceObject
local GivenPlot = game.ReplicatedStorage.BuildEvents.GivenPlot
local PlaceObject = game.ReplicatedStorage.BuildEvents.PlaceObject
local posX
local posY
local posZ
local YPos = Vector3.new(-1, 75, 0)
local Rot = 0
local Object
local Plot
local ButtonSoil = script.Parent.ScrollingFrame.Soil.ImageButton
local CanStart = true
IsPlacing = nil
local CanPlace = nil
GivenPlot.OnClientEvent:Connect(function(plt)
Plot = plt.Name
end)
local function Placement()
if IsPlacing and CanPlace then
PlaceObject:FireServer(posX, posY, posZ, Rot, Object.Name)
IsPlacing = false
CanPlace = false
CanStart = true
Object:Destroy()
end
end
local function TopDownView()
if IsPlacing then
local playerPos = Char:FindFirstChild("HumanoidRootPart").Position
local cameraPos = playerPos + YPos
Camera.CFrame = CFrame.new(cameraPos, playerPos)
end
end
local function Movement()
if IsPlacing and CanPlace and not CanStart and Mouse.Target and Mouse.Target.Name == Plot.Name then
Mouse.TargetFilter = Object
posX = math.floor(Mouse.Hit.X / 2 + 0.5)*2
posY = math.floor(Mouse.Hit.Y / 2 + 0.5)*2 -.5
posZ = math.floor(Mouse.Hit.Z / 2 + 0.5)*2
Object.Parent = workspace
Object:SetPrimaryPartCFrame(CFrame.new(posX, posY, posZ) * CFrame.Angles(0, math.rad(Rot), 0))
else
return Mouse.Hit.p
end
end
local function StartPlacementSoil()
if CanStart then
Object = game:GetService("ReplicatedStorage").Soil:Clone()
Object.Parent = workspace
Mouse.Move:Connect(Movement)
IsPlacing = true
CanPlace = true
CanStart = false
Mouse.Move:Connect(Movement)
end
end
local function Rotation(input, GPE)
if IsPlacing and CanPlace and not CanStart and input.KeyCode == Enum.KeyCode.R then
Rot = Rot + 90
Object:SetPrimaryPartCFrame(Object.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(Rot), 0))
end
end
Mouse.Button1Down:Connect(Placement)
ButtonSoil.MouseButton1Click:Connect(StartPlacementSoil)
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, TopDownView)
UIS.InputBegan:Connect(Rotation)

1 comment
If anyone could help it would be appreciated no one has helped because I've asked multiple times....