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

How to fire remote Event using user input service?

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.

1 comment

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

1 answer

fireEvent:FireServer()

2 comments

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

0

user input as far as im aware doesnt store the mouse 3d position so you'd have to use mouse.Hit.Position

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