So i am makeing a nuke where you can click a button and in 62 seconds a nuke will set off. This button is in a building and what im trying to do is that if you are standing in the building you will not die to the nuke. I added a part that i called safepart and the safepart cover the hole building and what I did is I tryed to check if the player was touching the safepart and if the player was touching the part they whould not die to the nuke. But something i notice is that when the nuke overlaps with the safepart it dose not detect the player is touching the safepart.
here is the code that is in the button
local Cd = script.Parent.ClassName
local Button = script.Parent
local NukeOn = false
local WaitTime = script.Parent.Parent.NukeWaitTime
local NukeLastTime = 10
local StopNuke = false
local NukeAmarm = game.Workspace:WaitForChild("NukeAlarm")
local SafePart = script.Parent.Parent.Parent.SafePart
local WaitTimeRestart = 62
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if NukeOn == false then
NukeOn = true
NukeAmarm["Nuke siren"]:Play()
script.Parent.Parent.Parent.NukeCounter.MainPart.SurfaceGui.TextLabel.TextTransparency = 0
while wait(1) do
WaitTime.Value -= 1
if WaitTime.Value <= 0 then
local Part = Instance.new("Part")
Part.BrickColor = BrickColor.new("New Yeller")
Part.Size = Vector3.new(0,0,0)
Part.Position = Vector3.new(0, -5, 0)
Part.Anchored = true
Part.Name = "Nuke"
Part.Parent = game.Workspace
Part.CanCollide = false
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://5694664687"
Sound.Volume = 10
Sound.Parent = Part
Sound:Play()
script.Parent.Parent.Parent.SafePart.SafeEvent.OnServerEvent:Connect(function(Player)
end)
script.Parent.Parent.Parent.UnSafePart.SafeEvent.OnServerEvent:Connect(function(Player)
end)
while wait() do
if StopNuke == false then
Part.Size += Vector3.new(1,1,1)
Part.Size += Vector3.new(1,1,1)
Part.Size += Vector3.new(1,1,1)
Part.Size += Vector3.new(1,1,1)
Part.Size += Vector3.new(1,1,1)
else
end
end
end
end
end
end)
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
while wait() do
if NukeOn == true then
wait(NukeLastTime)
if game.Workspace:FindFirstChild("Nuke") then
game.Workspace:FindFirstChild("Nuke"):Destroy()
NukeOn = false
WaitTime.Value = WaitTimeRestart
end
end
end
end)
and this is the building