So I am working on this game where you can spawn ships on it, but have no clue how to make it to where it detects if there is a ship already in that spot, so I tried writing this code but it doesn’t seem to be working can someone help?
script.Parent.MouseButton1Click:Connect(function()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local money = plr.leaderstats.Gold
if money.Value >= 500 then
if game.Workspace.ActiveShips.MainShipSpawn.Touched then
game.Workspace.ActiveShips.MainShipSpawn.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("MainPart") then
-- Do NOT spawn Ship
else
money.Value = money.Value - 500
game.ReplicatedStorage.Ships.Raft:Clone().Parent = game.Workspace.ActiveShips
game.Workspace.ActiveShips:FindFirstChild("Raft").Name = plr.Name
end
end)
end
end
end)