I was making a Plot System With Placement system But I ran into a Problem You can Objects Inside of objects, I tried to make a Touched Event for it But it didn’t work
Here is the Entire Script (Local Script for placing)
local Player = game.Players.LocalPlayer
local CarrotTool = script.Parent
local Mouse = Player:GetMouse()
local Placing = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MaterialSeedsFolder = ReplicatedStorage:WaitForChild("Seeds")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local PlotSystemBuildPart = MaterialSeedsFolder:WaitForChild(CarrotTool.Name):Clone()
PlotSystemBuildPart.Parent = nil
PlotSystemBuildPart.Anchored = true
PlotSystemBuildPart.CanCollide = false
PlotSystemBuildPart.CanTouch = true
PlotSystemBuildPart.Transparency = .4
CarrotTool.Equipped:Connect(function()
PlotSystemBuildPart.Parent = game.Workspace
Placing = true
end)
CarrotTool.Unequipped:Connect(function()
PlotSystemBuildPart.Parent = nil
Placing = false
end)
Mouse.Move:Connect(function()
if Placing == true then
local RayCastResult = workspace:Raycast(Mouse.Hit.Position + Vector3.new(0,150,0),Vector3.new(0,-250,0))
if RayCastResult ~= nil then
if RayCastResult.Instance.Name == "PlotSpace" and RayCastResult.Instance.Parent:WaitForChild("PlayerOwns").Value == Player.Name then
PlotSystemBuildPart.Position = RayCastResult.Instance.Position + Vector3.new(0,PlotSystemBuildPart.Size.Y/1,0)
end
end
end
end)
CarrotTool.Activated:Connect(function()
RemoteEvents.PlacingEvent:FireServer(CarrotTool, PlotSystemBuildPart.Position)
end)