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

How To Make It Last Man Standing?

Asked by 3 years ago

I have been trying to make this script teleport players one when player is remaining. I know how to make it so that it teleports you when one player is remaining, but, how do I reference the player if it is in a Model.

t=200 -- Focus On This Part To The Next Bookmark
    repeat
        t = t-1
        s.Value = t.." Seconds Left"
        wait (1)
        local ingame = workspace.Ingame:GetChildren()
    until t ==0 or #ingame == 0 or #ingame == 1 -- This means that 1 player is remaining, but I want to make to make it so that it displays the name on a text label. Since the charactor is a model with the name of the play I want to reference it but do not know how.

    if vals.Winner.Value ~= "" then
        s.Value = vals.Winner.Value.. " Has Won!" -- Focus till this part

game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +5
game.Players[vals.Winner.Value].leaderstats.Wins.Value = game.Players[vals.Winner.Value].leaderstats.Wins.Value +1

        vals.Winner.Value = ""
    else
        s.Value = "No One Won!" 
    end
    wait (3)
    local ingame = workspace.Ingame:GetChildren()
    for i =1,#ingame do
        local plr = game.Players:GetPlayerFromCharacter(ingame[i])
        plr:LoadCharacter()
    end
    workspace[curmap]:Destroy()

1 answer

Log in to vote
1
Answered by 3 years ago

You already are getting a player from a character on this line:

local plr = game.Players:GetPlayerFromCharacter(ingame[i])

You can use the same method, Players:GetPlayerFromCharacter(), and pass in the character model as a parameter.

Ad

Answer this question