So, i have a a user input thing where it sends a remote event to the server.
It doesn’t work, lets say if i press “R” and then i press “A” after, character will go left.
i press “R” and then “A” and it doesn’t work.
Heres the code
Stop wallrun
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WallrunRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("WallrunRemoteStop")
local WallrunRemote2 = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("WallrunKey")
local CoolDown = false
local CoolDown2 = false
local printer = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.R and gameProcessed == false and CoolDown == false then
CoolDown = true
WallrunRemote:FireServer()
UserInputService.InputBegan:Connect(function(input,gameProcessed)
if CoolDown2 == false and input.KeyCode ~= Enum.KeyCode.R then
CoolDown2 = true
if gameProcessed then return end
if printer then
print((input.KeyCode))
end
WallrunRemote2:FireServer(input.KeyCode)
task.spawn(function()
task.wait(.1)
CoolDown2 = false
end)
end
end)
task.spawn(function()
task.wait(.1)
CoolDown = false
end)
end
end)
Start wallrun code:
local UserInputService = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local Remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")
local WallrunRemote = Remotes:WaitForChild("WallrunRemote")
local WallrunRemoteStop = Remotes:WaitForChild("WallrunRemoteStop")
local WallrunTilt = Remotes:WaitForChild("WallrunTilt")
local value = script.Parent:WaitForChild("eValue")
local Character = script.Parent.Parent.Parent
local HRP = Character:WaitForChild("HumanoidRootPart")
local W = Enum.KeyCode.W
local A = Enum.KeyCode.A
local D = Enum.KeyCode.D
local CoolDown = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.E and gameProcessed == false and value.Value == false and CoolDown == false then
CoolDown = true
WallrunRemote:FireServer()
task.spawn(function()
task.wait(.1)
CoolDown = false
end)
end
end)
(Note: everything is on starter character script and is local script)
this is probably how the top script should be coded you had it with another inputbegan connection being made inside the first also you had a gameprocess return in the 2nd that would cause the cooldown2 to never become false again
Also I think you should take these 2 scripts use one userinpuservice connection and do everthing from there don’t see the need in 2 local scripts here
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WallrunRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("WallrunRemoteStop")
local WallrunRemote2 = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("WallrunKey")
local CoolDown = false
local CoolDown2 = false
local printer = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.R and gameProcessed == false and CoolDown == false then
CoolDown = true
WallrunRemote:FireServer()
task.spawn(function()
task.wait(.1)
CoolDown = false
end)
elseif CoolDown2 == false and input.KeyCode ~= Enum.KeyCode.R and gameProcessed == false then
CoolDown2 = true
if printer then
print((input.KeyCode))
end
WallrunRemote2:FireServer(input.KeyCode)
task.spawn(function()
task.wait(.1)
CoolDown2 = false
end)
end
end)
local function Space(tablexd,HRP)
WallrunRemoteStop.OnServerEvent:Connect(function(plr)
if printer then
print("r pressed")
end
WallrunRemote2.OnServerEvent:Connect(function(plr,key)
if printer then
print(key)
end
remove(HRP,tablexd,plr,key)
end)
end)
end
What it prints (printer on for both)
maybe i could put the keys down to one remote, if key is not R then bla bla bla. Not sure if it’ll work, tell me if i should do that or not
you shouldn’t have these connections inside of a function unless it is only going to be run once
then you have this one inside of the top connection which if you run that function create a connection to the first each time it runs then if this remote is called it creates the connection to the 2nd remote every time its called
these should all be delayed separately. its kinda the same issue you had on the local scripts
should look more like this:
WallrunRemoteStop.OnServerEvent:Connect(function(plr)
if printer then
print("r pressed")
end
end)
WallrunRemote2.OnServerEvent:Connect(function(plr,key)
if printer then
print(key)
end
remove(HRP,tablexd,plr,key)
end)
local function Space(tablexd,HRP)
local rPressed = false
WallrunRemoteStop.OnServerEvent:Connect(function(plr)
if printer then
print("r pressed")
rPressed = true
end
end)
WallrunRemote2.OnServerEvent:Connect(function(plr,key)
if printer then
print(key)
end
if rPressed then
remove(HRP,tablexd,plr,key)
end
end)
end
those should not be declared like that but by their self same as the one you just posted
if you do call it like this then the connection is not made until then also it is made multiple times
local function Space(tablexd,HRP)
local rPressed = false
WallrunRemoteStop.OnServerEvent:Connect(function(plr,key)
if printer then
print("r pressed")
end
if key == Enum.KeyCode.R then
rPressed = true
end
if key ~= Enum.KeyCode.R and rPressed and key == W or key == A or key == D then
remove(HRP,tablexd,plr,key)
end
end)
end
thanks so much for the help, wouldn’t have found the idea without your help!