When player dies with Tool in their hand, mobile buttons do not go away

Please show me a video of what happens so I can get a better understanding, this should’ve worked.

Uh any screen recorder suggestions, I cant use default roblox one in device emulation for some reason

Gyazo would be an alternative.

Sorry for the extremely late reply, my wifi went down down for 2 hrs, (idk why)
here is the video: https://gyazo.com/03a9c1be441dadae24133cc0a616452a

1 Like

this does not works and also gives an error @ElectricalSpy

No wonder why, you should’ve told me what you meant by UI because I thought it was referring to the player’s backpack, not an actual button. Please show me your button code.

My fault, I am not really good at making forum posts and also I have less then a year of experince with scripting. So I am very sorry if I wasted you time.
Here’s the script.

if UIS.TouchEnabled then
		local tossEnabled = true
		CAS:BindActionToInputTypes(
			'SpectralSword_Toss',
			function(name, state, input)
				if tossEnabled and state == Enum.UserInputState.Begin then
					tossEnabled = false
					spawn(function()
						script.Parent.KeyDown:FireServer('q', script.Parent.Parent.HumanoidRootPart.CFrame*Vector3.new(0, 0, -32))
						
						local button = CAS:GetButton('SpectralSword_Toss')
						button.ImageColor3 = Color3.new(1/2, 1/2, 1/2)
						wait(7)
						button.ImageColor3 = Color3.new(1, 1, 1)
						tossEnabled = true
					end)
				end
			end,
			true,
			''
		)

^^ Button being created.

script.Parent.Unequipped:connect(function()
	if UIS.TouchEnabled then
		CAS:UnbindAction('SpectralSword_Toss')
	end

^^^ Button being removed when unequipped.

game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
	if UIS.TouchEnabled then
		CAS:UnbindAction('SpectralSword_Toss')
	end
end)

^^^ My attempt, but it did not work unfortunately.

Players.Furkan5E.Backpack.SpectralSword.Input:73: attempt to index nil with 'Humanoid' 

^^^ Edit: My attempt gave this error

Try firing a remote event from the server and in the local script, when the event is received, UnBind it.

1 Like

These scripts I showed you were all in the client, so from the server I should fire a remote event and unbind it on the client?

Also when from the server to the client do I use FireServer() because I searched but found nothing.
EDIT: nevermind you use FireCilent() learnt somthing new today : )

I am really confused and I cant seem to get it to work…
nothing in output btw

player.CharacterAdded:Connect(function(character)
		character.Humanoid.Died:Connect(function()
            local ReplicatedStorage = game:GetService("ReplicatedStorage")
			local MobButtonRemove = ReplicatedStorage:WaitForChild("MobButtonRemove")
			MobButtonRemove:FireClient(player)

^^ server

local MobButtonRemove = ReplicatedStorage:WaitForChild("MobButtonRemove")

local function MobButtonRemoveFired(player)
	if UIS.TouchEnabled then
		CAS:UnbindAction('SpectralSword_Toss')
	end

	if GamepadButtonConnection then GamepadButtonConnection:disconnect() end
end

^^^ client

I know I am doing something wrong but I don’t know.

EDIT: I found what I did wrong!

MobButtonRemove.OnClientEvent:Connect(MobButtonRemoveFired)

^^^ missed one line of code…

1 Like

Thank you very much @WooleyWool It works now!

1 Like