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

Why doesn't this work after I die?

Asked by 9 years ago

This script is supposed to teleport you in and out of the lobby depending on if you're in the lobby or not. It works perfectly in studio but in game after I die i can't teleport out of the lobby but all the other button work. Works perfectly in studio though.

plr = game.Players.LocalPlayer
chr = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()
lobby = script.Parent.Lobby
timer = script.Parent.Timer
lp = lobby.Playing
points = script.Parent.Points
--Lobby--
lobby.MouseEnter:connect(function()
    for i = 1,25 do
        game:GetService("RunService").RenderStepped:wait()
        lobby.TextColor3 = Color3.new(lobby.TextColor3.r - .04,lobby.TextColor3.g - .04,lobby.TextColor3.b - .04)
        lobby.BackgroundColor3 = Color3.new(lobby.BackgroundColor3.r + .04,lobby.BackgroundColor3.g + .04,lobby.BackgroundColor3.b + .04)
        lobby.BorderColor3 = Color3.new(lobby.BorderColor3.r - .04,lobby.BorderColor3.g - .04,lobby.BorderColor3.b - .04)
    end
end)

lobby.MouseLeave:connect(function()
    for i = 1,25 do
        game:GetService("RunService").RenderStepped:wait()
        lobby.TextColor3 = Color3.new(lobby.TextColor3.r + .04,lobby.TextColor3.g + .04,lobby.TextColor3.b + .04)
        lobby.BackgroundColor3 = Color3.new(lobby.BackgroundColor3.r - .04,lobby.BackgroundColor3.g - .04,lobby.BackgroundColor3.b - .04)
        lobby.BorderColor3 = Color3.new(lobby.BorderColor3.r + .04,lobby.BorderColor3.g + .04,lobby.BorderColor3.b + .04)
    end
end)

lobby.MouseButton1Down:connect(function()
    for i = 1,25 do
        game:GetService("RunService").RenderStepped:wait()
        lobby.TextColor3 = Color3.new(lobby.TextColor3.r + .04,lobby.TextColor3.g + .04,lobby.TextColor3.b + .04)
        lobby.BackgroundColor3 = Color3.new(lobby.BackgroundColor3.r - .04,lobby.BackgroundColor3.g - .04,lobby.BackgroundColor3.b - .04)
        lobby.BorderColor3 = Color3.new(lobby.BorderColor3.r + .04,lobby.BorderColor3.g + .04,lobby.BorderColor3.b + .04)
    end
    local gui = Instance.new("ScreenGui",plr.PlayerGui)
    local frame = Instance.new("Frame",gui)
    frame.Size = UDim2.new(1,100,1,100)
    frame.BackgroundTransparency = 1
    frame.BackgroundColor3 = Color3.new(0,0,0)
    for i =  1,0,-.1 do
        game:GetService("RunService").RenderStepped:wait()
        frame.BackgroundTransparency = i
    end
    print (lp.Value)
    print (chr.Torso.Position)
    if lp.Value == false then
        lp.Value = true
        chr.Torso.CFrame = CFrame.new(232, 3, 10)
    else
        lp.Value = false
        chr.Torso.CFrame = CFrame.new(68, -142, -56)
    end
    print (lp.Value)
    print (chr.Torso.Position)
    for i =  0,1,.1 do
        game:GetService("RunService").RenderStepped:wait()
        frame.BackgroundTransparency = i
    end
    gui:Destroy()
end)

--Points--
local stat = plr.Points

points.Text = stat.Value.." Points"

stat.Changed:connect(function(change)
    points.Text = tostring(change).." Points"
end)
--Timer--

chr:WaitForChild("Humanoid").Died:connect(function()
    timer:WaitForChild("Time").Value = 0
    timer.Text = "Dead"
end)

timer.Time.Changed:connect(function()
    if timer.Time.Value ~= 0 then
        timer.Text = "Time Alive: ".. timer.Time.Value.. " Seconds"
    end
end)

Another problem is my timer doesn't count. When you're playing it's supposed to start counting, and when you're in the lobby it's supposed to stop.

repeat wait() until script.Parent.Parent.Parent.Lobby.Playing

print 'found'

t = script.Parent.Parent.Parent.Lobby.Playing
chr = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()
label = script.Parent.Parent
tim = script.Parent

while wait(1) do
    if t.Value == true then
        print 'true'
        if chr:WaitForChild('Humanoid').Health == 0 then
            tim.Value = 0
        else
            tim.Value = tim.Value + 1
        end
    end
end
0
Please stop constantly reposting the same question. woodengop 1134 — 9y
0
I'm not... I'm changing pass Senor_Chung 210 — 9y
0
@TheContinentofEurope i did mean to ask this question but not multiple times. I've also realized that I didn't post whole script or give a detailed explanation. Senor_Chung 210 — 9y

Answer this question