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

How do I get the mouse in a remote event script?

Hi, I'm having trouble with a script. I need help on how to make a part spawn at the mouse location when the remote event is fired. Here is the remote event script -

local RP = game:GetService("ReplicatedStorage")
local Event = RP.Whirlwind.GaleTornado
local Tornado = RP.effects.hiTornado

Event.OnServerEvent:Connect(function(player, text, Mouse)
	local character = player.Character or player.characterAdded:wait()
	local clonedTornado = Tornado:Clone()
	if text == "Pressed" then
		print("test")
		clonedTornado.CFrame = Mouse.CFrame
		clonedTornado.Parent = workspace
		
		
	end
end)

And here is the local script -

local UIS = game:GetService("UserInputService")
local attackTwo = Enum.KeyCode.X
local remoteMoveTwo = RP.Whirlwind.GaleTornado
local Mouse = game.Players.LocalPlayer:GetMouse()

UIS.InputBegan:Connect(function(input, gameProcessed, IsTyping)
	if(not gameProcessed) then
		if IsTyping or not equipped or debounce then return end
		if(input.KeyCode == attackTwo) then
			print("test")
			remoteMoveTwo:FireServer("Pressed" , Mouse)
		end
	end
end)

Any help would be appreciated :)

2 comments

0

There is no "isTyping" parameter for InputBegan.

0

Because it would techincally be nil, it won't even fire because it's not true.

1 answer

✓ Accepted answer

You cant send the mouse throught the remote event, but you can send the CFrame of the mouse through the remote event

like this

LS

local UIS = game:GetService("UserInputService")
local attackTwo = Enum.KeyCode.X
local remoteMoveTwo = RP.Whirlwind.GaleTornado
local Mouse = game.Players.LocalPlayer:GetMouse()

UIS.InputBegan:Connect(function(input, gameProcessed, IsTyping)
    if(not gameProcessed) then
        if IsTyping or not equipped or debounce then return end
        if(input.KeyCode == attackTwo) then
            print("test")
            remoteMoveTwo:FireServer("Pressed" , Mouse.Hit)
        end
    end
end)

S

local RP = game:GetService("ReplicatedStorage")
local Event = RP.Whirlwind.GaleTornado
local Tornado = RP.effects.hiTornado

Event.OnServerEvent:Connect(function(player, text, cframe)
    local character = player.Character or player.characterAdded:wait()
    local clonedTornado = Tornado:Clone()
    if text == "Pressed" then
        print("test")
        clonedTornado.CFrame = cframe
        clonedTornado.Parent = workspace


    end
end)

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