Could Someone help me? I was Making a Build System for my Plot System But There is a Problem with that You can Place Blocks Into each other Please Help, I tried Making touched event but its not working. Any help is appreciated
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,0)
end
end
end
PlotSystemBuildPart.Touched:Connect(function(Hit) -- Touched Event Here
if Hit.Name == MaterialSeedsFolder:FindFirstChild(Hit.Name).Name then
PlotSystemBuildPart.Color = Color3.new(1, 0.2, 0.2)
else
PlotSystemBuildPart.Color = MaterialSeedsFolder:WaitForChild(CarrotTool.Name).Color
end
end)
end)
I will have a read in the morning, but there was quite a bit of convolution there! I will help if I can, but I can’t now. It’s too late here in the UK and just looking at that has already made me start to chew!
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”)
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
That’s the Whole Script (Its a local script inside of a tool)
What I’m basically trying to do is Make the blocks Can’t touch other parts except “PlotSpace” or else it will destroy if it touches
There is a Property inside it Called CanTouch
Also I have to make it anchored and Collision off Because I’m making a farming game where you Place seeds and this is basically where you will place it , I don’t know what to do I’m lost
if PlotSystemBuildPart then
PlotSystemBuildPart.Touched:Connect(function(Hit) -- Touched Event Here
if Hit.Name == MaterialSeedsFolder:FindFirstChild(Hit.Name).Name then
PlotSystemBuildPart.Color = Color3.new(1, 0.2, 0.2)
else
PlotSystemBuildPart.Color = MaterialSeedsFolder:WaitForChild(CarrotTool.Name).Color
end
end)
end