Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Fix This Teleport After Night Script?

Asked by
Donut792 216 Moderation Voter
5 years ago

alright so in my game i have a detection for if a player is inside a building when it turns night they will be teleported outside of the building which works fine but it teleports even if they are miles away after touching the part and does it every night instead of just one

script:

 script.Parent.Position = Vector3.new(-850.129, 16.661, 90.244)

    script.Parent.Size = Vector3.new(30.07, 25.05, 31.28)

    local kickbounce = false

    local l = game.Lighting

    script.Parent.Touched:Connect(function(hit)

    if hit.Parent.ClassName == "Accessory" then

    local player = game.Players:FindFirstChild(hit.Parent.Parent.Name)

    else

    local player = game.Players:FindFirstChild(hit.Parent.Name)

    while true do

    wait(5)

    if l.ClockTime >= 6 and l.ClockTime <= 22 then

    kickbounce = false

    if l.ClockTime == 21 then

    local clone = script.NightWarning:Clone()

    clone.Parent = player.PlayerGui -- this also doesn't work but doesn't print any errors

    end

    end

    if l.ClockTime <=5.9 or l.ClockTime >= 22.1 then

    if kickbounce == false then

    player.Character.HumanoidRootPart.CFrame = script.Parent.Parent.PastClosingTimeTele.CFrame

    kickbounce = true

    end

    end

    end

    end

    end)
0
Use :WaitForChild("PlayerGui") when getting the PlayerGui tree_tree00 48 — 5y

Answer this question