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

The remote event wont fire and i have no idea how to fix this?

local plr = game.Players.LocalPlayer
local char = plr.Character
local UIS = game:GetService("UserInputService")
local Mouse = plr:GetMouse()
---------------------------------------------
local RP = game:GetService("ReplicatedStorage")
local Remote = RP.FireBallRemote
--------------------------------------
local Debounce = true
local Key = "Z"
local ButtonDown = false

UIS.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end
	local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] and Debounce and char then
		Debounce = false
		ButtonDown = true
		Remote:FireServer(ButtonDown, Mouse.Hit,UIS)
		print("fired")
	end 
end)

1 answer

✓ Accepted answer

Client

local plr = game.Players.LocalPlayer
local char = plr.Character
local UIS = game:GetService("UserInputService")
local Mouse = plr:GetMouse()
---------------------------------------------
local RP = game:GetService("ReplicatedStorage")
local Remote = RP.FireBallRemote
--------------------------------------
local Debounce = true
local Key = "Z"
local ButtonDown = false

UIS.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] and Debounce and char then
        Debounce = false
        ButtonDown = true
        Remote:FireServer(ButtonDown, Mouse.Hit,UIS)
        print("fired")
    end 
end)

Server

local UIS = game:GetService("UserInputService")
Remote.OnServerEvent:Connect(function(Player,Down,HitPosition)
	-- code here
end)

2 comments

0

thx i will try this

0

player is always the first variable in a remote

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