Inside of a LocalScript, there is a function that I used :BindAction() on set to create a mobile button as well as look for input from 'Z'. It works and does its job up until the point where the player respawns. The mobile button no longer appears when the player respawns, but pressing 'Z' on a desktop platform still triggers the function and dies its job.
Any idea of what I'm doing wrong? Please note that the code is in a LocalScript that starts in StarterGui before the game starts.
local repstor = game:GetService("ReplicatedStorage")
local func = repstor:WaitForChild("RemoteFunction")
local conser = game:GetService("ContextActionService")
local st = false
local fir = false
local player = game.Players.LocalPlayer
local char = player.Character
if not char or char.Parent == nil then
char = player.CharacterAdded:wait()
end
local hum = char:FindFirstChild("Humanoid")
print('loaded local slide')
function slideZ(str, state, obj)
if st == false and state == Enum.UserInputState.Begin then
st = true
local t = func:InvokeServer("SlideAnim")
repeat wait() until t == true
if t == true then
print('finished slide')
st = false
end
end
end
conser:BindAction("Slide", slideZ, true, "z")
