Input issue with character function

Hello, I have an issue with this script. I made this script so that if I press on F, it’ll enable particles (particles’ parent is players’ character). Thought, when I press on F, it does nothing and doesn’t enable particles. This is a server script that I put in ServerScriptService. Please help me fix this issue.

local UIS = game:GetService("UserInputService")
local marketplace = game:GetService("MarketplaceService")
local gamepass = 53518831
local x = false

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if marketplace:UserOwnsGamePassAsync(player.UserId, gamepass) then
			UIS.InputBegan:Connect(function(Input)
				if Input.KeyCode == Enum.KeyCode.F and x == false then
					character.Chest1.Flame.Fire.Enabled = true
					character.Chest1.Flame2.Fire.Enabled = true
					x = true
					
				elseif Input.KeyCode == Enum.KeyCode.F and x == true then
					character.Chest1.Flame.Fire.Enabled = false
					character.Chest1.Flame2.Fire.Disabled = false
					x = false
				end		
			end)
		end
	end)
end)

Do you mind adding a print under both UserInput events to see if they print? Thankyou

1 Like

If I am not mistaken, you can’t use UserInput Service in a server script.
You’d have to use remote events or remote functions.