I KNOW KEYDOWN IS DEPRECATED!!!
Alright, after more help I could do it and do my script. Now, I'd like to make the script work again when the caster or the objective dies. If you are new and you haven't seen my old question that's what I've done thanks to this great community:
-Choosing a player with Mouse -Pressing Z -Deactivating a script located in their playergui
And that's done with the following script:
local players = game:GetService("Players")
local mouse = game.Players.LocalPlayer:GetMouse()
local advertisement = game.Players.LocalPlayer.PlayerGui.Erasure:WaitForChild("Advertisement")
local nome = ""
mouse.KeyDown:connect(function(k)
k = k:lower()
if k == 'z' then
--This makes appear a textlabel that says his script has been deactivated
if game.Players.LocalPlayer.Backpack.ErasedValue.Value == "true" then
local target = mouse.Target
local humanoid = target.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = humanoid.Parent
local nomeplayer = players:GetPlayerFromCharacter(character)
local nome = humanoid
advertisement.Visible = true
advertisement.TextLabel.BackgroundTransparency = 0.2
advertisement.TextLabel.TextTransparency = 0.2
wait(0.7)
advertisement.Visible = true
advertisement.TextLabel.BackgroundTransparency = 0.4
advertisement.TextLabel.TextTransparency = 0.4
wait(0.7)
advertisement.TextLabel.BackgroundTransparency = 0.6
advertisement.TextLabel.TextTransparency = 0.6
wait(0.7)
advertisement.TextLabel.BackgroundTransparency = 0.8
advertisement.TextLabel.TextTransparency = 0.8
wait(0.7)
advertisement.TextLabel.BackgroundTransparency = 1
advertisement.TextLabel.TextTransparency = 1
wait(0.7)
advertisement.Visible = false
--That's the new thing, it didn't work though. Help, please?
if nome.Health >= 0 then
nomeplayer.Backpack.ErasedValue.Value = "false"
elseif game.Players.LocalPlayer.Character.Humanoid.Health >= 0 then
nomeplayer.Backpack.ErasedValue.Value = "false"
end
end
else
--This deactivates other people's script.
local target = mouse.Target
local humanoid = target.Parent:FindFirstChild("Humanoid")
if humanoid then
local character = humanoid.Parent
local nomeplayer = players:GetPlayerFromCharacter(character)
local nome = nomeplayer
if nomeplayer.Backpack.ErasedValue.Value == "false" then
nomeplayer.Backpack.ErasedValue.Value = "true"
end
end
end
end
end
end)
I count on you this time too! Thanks for your help.

1 comment
KeyDown is deprecated.