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

How do I get a Character Removing method to work?

Does character removing method need to be in a local script? cause it apparently doesn't seem to be working in a script. Can someone help me find out why it's not working?? When the value of the person dies it would only print the name that died and nothing else.

script.Parent.Changed:connect(function() if game.Players:FindFirstChild(script.Parent.Value) then local kk = game.Workspace:FindFirstChild(script.Parent.Value) local jk = Instance.new("StringValue",kk) jk.Name = "FightingForBlue" local k = game.Players:FindFirstChild(script.Parent.Value) k.CharacterRemoving:connect(function(character) print(k.Name .. " has died.") wait(0.5) if k:FindFirstChild("BlueFighter") then blueo() elseif k:FindFirstChild("King") then kingo() end end) end end)

function blueo() local err = script.Parent.Parent.Parent.Er if game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") ~= nil then print("Tie") err.Value = 8 elseif game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") then print("Green won that round!") err.Value = 12 game.Players:FindFirstChild(script.Parent.Value).TeamColor = BrickColor.new("Mid gray") game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("Head"):Remove() game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("Head"):Remove() end end

function kingo() print("Started Kingo") local err = script.Parent.Parent.Parent.Er if game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") ~= nil then print("No one wins the tournament.") err.Value = 60 elseif game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") then print("Green Won!") err.Value = 20 end end

2 comments

0

Please put the code in a code block, makes it easier to read.

0

I don't know how to.

4 answers

Could you use code block? Then I might be able to answer your question.

2 comments

0

How?

0

Press edit and then put the script in code block. To get code block press the code block button.

Click on the lua button then paste the code into it

Does character removing method need to be in a local script? cause it apparently doesn't seem to be working in a script. Can someone help me find out why it's not working?? When the value of the person dies it would only print the name that died and nothing else.

script.Parent.Changed:connect(function()
if game.Players:FindFirstChild(script.Parent.Value) then
local kk = game.Workspace:FindFirstChild(script.Parent.Value)
local jk = Instance.new("StringValue",kk)
jk.Name = "FightingForBlue"
local k = game.Players:FindFirstChild(script.Parent.Value)
k.CharacterRemoving:connect(function(character)
print(k.Name .. " has died.")
wait(0.5)
if k:FindFirstChild("BlueFighter") then
blueo()
elseif k:FindFirstChild("King") then
kingo()
end
end)
end
end)

function blueo()
local err = script.Parent.Parent.Parent.Er
if game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") ~= nil then
print("Tie")
err.Value = 8
elseif game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") then
print("Green won that round!")
err.Value = 12
game.Players:FindFirstChild(script.Parent.Value).TeamColor = BrickColor.new("Mid gray")
game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("Head"):Remove()
game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("Head"):Remove()
end
end

function kingo()
print("Started Kingo")
local err = script.Parent.Parent.Parent.Er
if game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") ~= nil then
print("No one wins the tournament.")
err.Value = 60
elseif game.Workspace:FindFirstChild(script.Parent.Value):FindFirstChild("FightingForBlue") ~= nil and game.Workspace:FindFirstChild(script.Parent.Parent.Parent.Green.Fighting.Value):FindFirstChild("FightingForGreen") then
print("Green Won!")
err.Value = 20
end
end

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