Hi, I have a tool, when a player on mobile dies there mobile buttons for the tool ability is just stuck on the screen. I don’t know what to do.
If you need any scripts just ask.
Hi, I have a tool, when a player on mobile dies there mobile buttons for the tool ability is just stuck on the screen. I don’t know what to do.
If you need any scripts just ask.
In the future, always provide the code. We shouldn’t have to ask so that we can help you.
Are these mobile buttons the Roblox default ones or custom made UI buttons? If they are custom made, fire a remote event upon the death of the player to hide them.
Sorry about that, I’ll put the script in the main post.
Default Roblox ones, I am modifying a gear.
Destroy the tools in the player’s backpack and character.
OK, I’ll try that real quick and see if that works.
do a
game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
deleteguislol
end)
// just put a Script inside PlrCharacter
script.Parent.Humanoid.Died:connect(function()
guiDestroyherelol
end)
@ElectricalSpy’s suggestion will not work, you’ll need to do the following in a server script:
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character
charcter.Humanoid.Died:Connect(function()
player.Backpack.Tool:Destroy()
end)
end)
I don’t have tool defined, players can pick up tools from the map. could you give me a hand please?
I think Instance:IsA will work?
In player backpack, you can do a for loop like so:
for i, v in pairs(player.Backpack:GetChildren()) do
v:Destroy()
end
It’s not PlayerBackpack, it’s Backpack.
In the character, you can do the following:
for i, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
v:Destroy()
end
end
??? I never said its a localscript,
// just put a Script inside PlrCharacter
script.Parent.Humanoid.Died:connect(function()
–guiDestroyherelol
end)
the “–guiDestroyherelol” is where he puts his gui destroy thingy, which basically means
script.Parent.Humanoid.Died:connect(function()
local tool = script.Parent:FindFirstChildOfClass("Tool")
if tool then
tool:Destroy()
end
end)
In pictures:
I assumed it’s a local script because you did game.Players.LocalPlayer - this can only be done in a local script.
I am done I will test give me a second please, also Thank you.
I did list up 2 versions.
1st is to local remove the guis from the plr’s guis.
You don’t do any of these, you can detect the died event in a normal script in ServerScriptService.
The GUIs are built-in, you can only get rid of them once the tool is deleted and the UI will be removed automatically.
True. But that way its easier, less bugs^^
What bugs would occur? There are no bugs, your method is not efficient.
Uh, I tried and it didn’t work.
This is my script btw
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1
-- Whenever somebody dies, this event will run
if character.Humanoid and character.Humanoid:FindFirstChild("creator") then
game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value).." Killed "..player.Name
character.Humanoid.creator.Value.leaderstats.Kills.Value = character.Humanoid.creator.Value.leaderstats.Kills.Value + 1
wait(1)
end
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
for i, v in pairs(player.Backpack:GetChildren()) do
v:Destroy()
end
for i, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
v:Destroy()
end
end
player:LoadCharacter()
end)
end)
Did any error occur? Please tell me this information.
Nothing in the output. I checked