Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Player death kick script problem?

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

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)

4 comments

0

@Subz for some reason it doesnt work

0

@Subsz ts a local script in SSS btw

0

:connect() is deprecated. Use :Connect()

0

I think you should do it in a server script

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)
--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)

This discussion is preserved as it was. New answers, comments, and votes are closed.