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

Player death kick script problem?

Asked by 4 years ago
maxDeaths = 1

game.Players.PlayerAdded:connect(function(p)
local hold = Instance.new("IntValue", p)
hold.Name = "Deaths"
p.CharacterAdded:connect(function(c)
c.Humanoid.Died:connect(function()
hold.Value = hold.Value +1
if hold.Value == maxDeaths then
Player:kick("I am dead. So why am I back ")
end
end)
end)
end)

the "Player" thing is underlined blue and says "unknown global 'player'" why does it say that?

3 answers

Log in to vote
0
Answered by
Subsz 366 Moderation Voter
4 years ago
Edited 4 years ago

You've defined player as 'p', so do p:Kick()

maxDeaths = 1

game.Players.PlayerAdded:connect(function(p)
local hold = Instance.new("IntValue", p)
hold.Name = "Deaths"
p.CharacterAdded:connect(function(c)
c.Humanoid.Died:connect(function()
hold.Value = hold.Value +1
if hold.Value == maxDeaths then
p:Kick("I am dead. So why am I back ")
end
end)
end)
end)
0
@Subz for some reason it doesnt work MartinPlayzPokemonGo 2 — 4y
0
@Subsz ts a local script in SSS btw MartinPlayzPokemonGo 2 — 4y
0
:connect() is deprecated. Use :Connect() KingDomas 153 — 4y
0
I think you should do it in a server script IceyTazeForLife 253 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

try this

maxDeaths = 1

game.Players.PlayerAdded:connect(function(p)
local hold = Instance.new("IntValue", p)
hold.Name = "Deaths"
p.CharacterAdded:connect(function(c)
c.Humanoid.Died:connect(function()
hold.Value = hold.Value +1
if hold.Value == maxDeaths then do
Player:kick("I am dead. So why am I back ")
end
end
end)
end)
Log in to vote
0
Answered by 4 years ago
--THIS "SHOULD" BE WRITTEN IN A SCRIPT

local maxDeaths = 1

game.Players.PlayerAdded:Connect(function(p)
    local hold = Instance.new("IntValue", p)
    hold.Name = "Deaths"

    p.CharacterAdded:Connect(function(c)
        c.Humanoid.Died:Connect(function()
            hold.Value = hold.Value + 1

            if hold.Value == maxDeaths then
                p:Kick("I am dead, So why am I back")
            end
        end)
    end)
end)

Answer this question