Hello, I’m making an HouseSystem, and I want that when a player spawns the house, and an another player is in the spawn area or is in the position of a table for example, the script simple bump the player away. I tried to use Touch, but I don’t think it’s the best way, so anyone has a better idea ?
local Gui = script.Parent.Parent.Parent.Parent
local ServerStorage = game:GetService("ServerStorage")
local House1 = ServerStorage.Houses.House1
local Camera1 = House1.Camera1
local Camera2 = House1.Camera2
local TouchPart = workspace.Plot1.TouchPart
local Area = workspace.Plot1.HouseTeleport
local CloseButton = script.Parent.Parent.Parent.Close
local RemoteEvent = script.Parent.Teleport
local ServerStorage = game:GetService("ServerStorage")
local House2Script = script.Parent.Parent.HouseSpawn2.HouseSpawnCore2
local Camera = script.Parent.Parent.Parent.Parent.UpperBottons.CamerasCall
local UpperButtons = script.Parent.Parent.Parent.Parent.UpperBottons
local BarCall = script.Parent.Parent.Parent.Parent.BarCall
-- Here I'm going to make the script--
script.Parent.MouseButton1Click:Connect(function()
--TouchPart.CanTouch = true
workspace.HousesSpawn.Plot1:ClearAllChildren()
script.Disabled = true
House2Script.Disabled = false
RemoteEvent.OnServerEvent:Connect(function(x, argument)
while wait(3) do
for i, part in pairs(TouchPart:GetTouchingParts()) do
if part.Name == "HumanoidRootPart" then
print("found")
part.CFrame = CFrame.new(Area.CFrame)
end
end
wait()
end
--x.Character:FindFirstChild("HumanoidRootPart", 1).CFrame = CFrame.new(Area.Position)
end)
House1:Clone().Parent = workspace.HousesSpawn.Plot1
workspace.HousesSpawn.Plot1:FindFirstChild("House1").PrimaryPart.Position = Vector3.new(-32.726, 14.893, -252.148)
Camera1:Clone().Parent = workspace.HousesSpawn.Plot1
Camera2:Clone().Parent = workspace.HousesSpawn.Plot1
Camera.Visible = true
CloseButton.Visible = true
UpperButtons.Visible = true
BarCall.Visible = true
for i,v in ipairs(workspace.Plot1.Details:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
elseif v:IsA("SurfaceGui") then
v.Enabled = false
end
end
wait(0.5)
TouchPart.CanTouch = false
end)