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

why won't my remote event work, no errors how do i fix it?

local script


	local Replstorage = game:GetService("ReplicatedStorage")
	local userinput= game:GetService("UserInputService")
	
	local player = game.Players.LocalPlayer
	local Mouse = player:GetMouse()
	
	local Remote = Replstorage:WaitForChild("Zap")

	userinput.InputBegan:Connect(function(Input,Istyping)
		if Istyping then return end
		local keypressed = Input.KeyCode
		if keypressed == Enum.KeyCode.X then
			Remote:FireServer(Mouse.Hit)
			print("2sx")

		end
			
		
	end)

script




	local Replstorage = game:GetService("ReplicatedStorage")
	local Remote = Replstorage:WaitForChild("Zap")

Remote.OnServerEvent:Connect(function()
	print("worked")
local p = Instance.new("Part")
p.Parent = workspace
end)

1 comment

0

are you getting the "worked" msg

1 answer

I dont know why peoples use "Istyping", it's not necessary. Just write this like that:

userinput.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.X then
		print("2sx")
		Remote:FireServer(Mouse.Hit)
	end
end)

Now it's work!:)

4 comments

0

And for information the first variable returned by the RemoteEvent when this one is called by the client is the client, the second variable is your arguments sended.

0

Remote.OnServerEvent:Connect(function(Player, MouseHit)

1

"Istyping" is called gameProcessedEvent. With it you can determinate if the player is focused on a TextBox or not. You can use this to prevent running a Script if the player is typing in the chat. It is very useful.

0

Thanks for the information

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