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

How to fire remote Event using user input service?

Asked by 3 years ago

What line of code would I use to to Fire A Remote Event using User Input Service after the character presses MouseButton1?

I have so far this:

local gun = script.Parent
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fireEvent = ReplicatedStorage:WaitForChild("Fire")

local function onInputBegan(input, gameProcessed)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then

    end
end

line 8 is the code I am missing but i'm unsure what to use.

0
Do you mean like ReplicatedStorage.Fire:FireServer(mouse.Hit) because you need to call the mouse by defining the player like player = game.players.Localplayer and local character = player.Character or player.CharacterAdded:Wait() then local mouse = player:GetMouse() then mouse.TargetFilter = character iamajunky 20 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

fireEvent:FireServer()

0
I know that part but don't I have to provdie the Remote Event with info? I found this line: fireEvent:FireServer(gun.Handle.Position, mouse.Hit.p) But that uses mouse and I want to use User Input Service carlover38 0 — 3y
0
user input as far as im aware doesnt store the mouse 3d position so you'd have to use mouse.Hit.Position Gameplayer365247v2 1055 — 3y
Ad

Answer this question