Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)
0
are you getting the "worked" msg ffancyaxax12 181 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!:)

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. NiniBlackJackQc 1562 — 4y
0
Remote.OnServerEvent:Connect(function(Player, MouseHit) NiniBlackJackQc 1562 — 4y
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. JakyeRU 637 — 4y
0
Thanks for the information NiniBlackJackQc 1562 — 4y
Ad

Answer this question