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

FireServer is not a valid member of UserInputService "Instance"?

Righty, so I've encountered a little problem while trying to script a.. simple, as I thought, thing. Keep in mind, however: I am not just a beginning scripter; I've began like... about a week ago; so if the mistake is obvious, I ask you not to be too harsh. Now here is the code that I am using (it's a LocalScript)

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local openDoor = game:GetService("UserInputService")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		if Mouse.Target then
			openDoor:FireServer(Mouse.Target)
		end
	end
end)

local peeking = false

while true do
	wait()
	if Mouse.Target == workspace.Door then
		if peeking == false then
			peeking = true
			local bClone = script.Parent.Button:Clone()
			bClone.Parent = workspace.CurrentCamera
			bClone.Adornee = workspace.Door
			bClone.TextLabel.Visible = true
		end
	else 
		if peeking == true then
			if workspace.CurrentCamera:FindFirstChild("Button") then
				workspace.CurrentCamera.Button:remove()
				peeking = false
			end
		end
	end
end

And here is the problem: When pressing "E" on the supposed door, the door does not react and an error pops up in the console, stating: "FireServer is not a valid member of UserInputService "Instance" "

How can I fix this, if a fix is possible?

1 answer

The answer to your question is that the UserInputService is a service and doesn't have a function for what you're trying to call.

FireServer()

however is a function of a RemoteEvent. If you want to look more into RemoteEvents you can visit this article on the roblox api reference.

Some advice I can give you for setting up what you're trying to do with this script would be to use a ClickDetector with a function attached to the MouseEnter and MouseLeave events.

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