My script only fires UserInputService before dying
spawnTracker.OnClientEvent:Connect(function() ← The script checks when the player spawns and this part works fine
print(“Spawned”)
if Stand.Value == “The Hand” then
print("Passed Check") <-- **The Script passes the If then statement after dying**
UIS.InputBegan:Connect(function(input, isTyping) <-- The Event doesn't fire
print("Fire Function") <-- This doesn't show in the output after dying
ZaHando(input, isTyping)
end)
Formatted version of the script so anyone else trying to solve it can read it smh
spawnTracker.OnClientEvent:Connect(function()
print(“Spawned”)
if Stand.Value == “The Hand” then
print("Passed Check") -- The Script passes the If then statement after dying
UIS.InputBegan:Connect(function(input, isTyping)
print("Fire Function") -- This doesn't show in the output after dying
ZaHando(input, isTyping)
end)
end
end)
btw the script contains OnClientEvent meaning it is a server script, but then attempts to use input began??? use UIS in a localscript it wont work on the server
Also, Player.CharacterAdded, fires when a player respawns/spawns in. Dont do player.Character.Humanoid.Died. Player.CharacterAdded already does that for you.
I’m assuming this script is a local script, which is placed in StarterPlayerScripts.
When a player spawns, all scripts located in StarterPlayerScripts resets. If you want to fix this issue, you can make a variable and set the value to true whenever the Remote is fired.
local Enabled = false
spawnTracker.OnClientEvent:Connect(function()
if Stand.Value == “The Hand” then
Enabled = true
end
end)
UIS.InputBegan:Connect(function(input, isTyping)
if Enabled then
print("Fire Function")
ZaHando(input, isTyping)
end
end)
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
if not Character or not Character.Parent then
Character = Player.CharacterAdded:wait()
end
local UIS = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local theHand = rp:WaitForChild("RemoteEvents"):WaitForChild("The Hand")
local spawnTracker = rp:WaitForChild("RemoteEvents"):WaitForChild("PlayerSpawned")
local Active = script.Parent.Parent.Parent
local debounce = false
local Stand = Player:WaitForChild("Stand")
local thCheck = false
local inputControl
local function ZaHando(input, isTyping)
print("Input Sent")
if Stand.Value == "The Hand" and Active:GetAttribute("Active") == false then
print("Input Valid")
local CharacterStand = Character:FindFirstChild("The Hand", true)
if CharacterStand then
print("The Hand Found")
if isTyping then
return
elseif input.KeyCode == Enum.KeyCode.E then
if not debounce then
debounce = true
Active:SetAttribute("Active", true)
theHand:FireServer("E")
end
elseif input.KeyCode == Enum.KeyCode.F then
if not debounce then
debounce = true
Active:SetAttribute("Active", true)
theHand:FireServer("F")
end
elseif input.KeyCode == Enum.KeyCode.R then
if not debounce then
debounce = true
Active:SetAttribute("Active", true)
theHand:FireServer("R")
end
elseif input.KeyCode == Enum.KeyCode.T then
if not debounce then
debounce = true
Active:SetAttribute("Active", true)
theHand:FireServer("T")
end
elseif input.KeyCode == Enum.KeyCode.Y then
if not debounce then
debounce = true
Active:SetAttribute("Active", true)
theHand:FireServer("Y")
end
end
end
end
end
spawnTracker.OnClientEvent:Connect(function()
print("Spawned")
if Stand.Value == "The Hand" then
print("Passed Check")
UIS.InputBegan:Connect(function(input, isTyping)
print("Fire Function")
ZaHando(input, isTyping)
end)
end
end)
Character:WaitForChild("Humanoid").Died:Connect(function()
print("rip")
end)
theHand.OnClientEvent:Connect(function()
Active:SetAttribute("Active", false)
debounce = false
end)