I've been working on a Spider-Man Physics game for the longest but just got back into coding after a few years. I had the RopeConstraint's Length change over on the client side but wanting to push it to the server side. I did change up the code a lot from when it worked on the client side but STRUGGLING! I did leave some comments in the code aswell.
My question to you is, how would you go about making this code work to where if they hit the key "Q", the rope reduces length. If "E" then, it adds length. But, I don't want the player's input to override so that way the rope doesn't bug out.
---------------------------------------------------[[ ServerScript
--// Web Length Controller
WebLengthRemote.OnServerInvoke = function(Player,Request,HoldingKey)
local Character = Player.Character
local HumanoidRP = Character:FindFirstChild('HumanoidRootPart')
local LeftHand = Character:FindFirstChild('LeftHand')
local Rope = LeftHand:FindFirstChild('RopeConstraint')
if Request == 'Q_ClimbUp' and Rope then
if HoldingKey == true then
while HoldingKey == true and Rope do
wait()
Rope.Length = Rope.Length - 4
end
end
elseif Request == 'E_ClimbDown' and Rope then
if HoldingKey == true then
while HoldingKey == true and Rope do
wait()
Rope.Length = Rope.Length + 4
end
end
elseif Request == 'StopAll' then
WebLengthRemote.OnServerInvoke = nil -- Wanting to stop the rope's length from increasing and decreasing
end
end
---------------------------------------------------[[ LocalScript
--Trying to detect when the player holds down 'Q' or 'E', it should run the function on the server side but with the given "Request" argument.
local HoldingKey = false
--// Climbing Web
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q and Input.KeyCode ~= Enum.KeyCode.E then -- Trying to disable players from holding the same key down so the rope doesn't bug out
local Request = 'Q_ClimbUp'
if HoldingKey == false then
HoldingKey = true
print(HoldingKey)
WebLengthRemote:InvokeServer(Request,HoldingKey)
end
end
end)
--// Release Web
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E and Input.KeyCode ~= Enum.KeyCode.R then
local Request = 'E_ClimbDown'
if HoldingKey == false then
HoldingKey = true
print(HoldingKey)
WebLengthRemote:InvokeServer(Request,HoldingKey)
end
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q or Input.KeyCode == Enum.KeyCode.E then
local Request = 'StopAll'
HoldingKey = false
print('Stopped holding every key')
WebLengthRemote:InvokeServer(Request,HoldingKey)
end
end)
You are my life saver :) If you are willing to contact me, I have discord @Previized#7500
