Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

UserInputService not working on first life?

wait(1)

local plr = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input,isTyping)
	local equip = plr:FindFirstChild("Equips")
	local ability = equip:FindFirstChild("Ability1")
	local folder = ability:FindFirstChildOfClass("Folder")
	
	if folder then
		print("ok")
		local event = folder:FindFirstChild("FireEvent")
		if input.KeyCode == Enum.KeyCode.Q then
			event:FireServer()
		end
	end
end)

It's fine when I reset character for the first time, but not the first time you join. It's supposed to fire a server event, but only works when you've been in the game and died the first time. The script works, its just a problem with UIS. Does anyone know why?

1 answer

✓ Accepted answer

You can just do:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr:LoadCharacter()
end)

Put that inside a normal script (server script) and put the script inside of workspace or server script service

This discussion is preserved as it was. New answers, comments, and votes are closed.