what is causing this issue?
it multiplies decrease and increase value after i use leash remover
i spent really long time trying to find a solution but i still didn’t
Leash server:
script.Parent:WaitForChild("RemoteEvent")
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, target)
local ropeconstraint = Instance.new("RopeConstraint")
local attachment0 = Instance.new("Attachment")
local attachment1 = Instance.new("Attachment")
local Distance = (player.Character.HumanoidRootPart.Position - target.Position).Magnitude
local maxDistance = 50
local minimumLength = 5.5
local decrease = 0.4
local increase = 0.4
local blocks = target.Parent
if blocks.Name == player.Name and (player.Character.HumanoidRootPart.Position - target.Position).Magnitude < maxDistance then
attachment0.Parent = target
attachment1.Parent = script.Parent.Parent.Torso
ropeconstraint.Attachment0 = attachment0
ropeconstraint.Attachment1 = attachment1
ropeconstraint.Color = BrickColor.new("Black")
ropeconstraint.Visible = true
ropeconstraint.Parent = script.Parent.Parent.Torso
ropeconstraint.Length = Distance
script.Parent.RemoteEvent2.OnServerEvent:Connect(function()
ropeconstraint.Length += increase
print(increase)
end)
script.Parent.RemoteEvent3.OnServerEvent:Connect(function()
player.Character.Torso.Anchored = true
ropeconstraint.Length -= decrease
print(decrease)
wait(0.01)
player.Character.Torso.Anchored = false
end)
while wait(0.01) do
if ropeconstraint.Length < minimumLength then
ropeconstraint.Length = minimumLength
decrease = 0
end
end
while wait(0.01) do
if ropeconstraint.Length > minimumLength then
decrease = 0.4
end do
end
end
end
end)
Leash Client:
local keyPressed = false
local keyPressed2 = false
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
script.Parent.RemoteEvent:FireServer(mouse.Target, mouse.TargetSurface)
end)
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.E then
print("E")
script.Parent.RemoteEvent2:FireServer()
end
end
end)
UserInputService.InputBegan:Connect(function(inputObject2, gameProcessedEvent2)
if not gameProcessedEvent2 then
if inputObject2.KeyCode == Enum.KeyCode.Q then
print("Q")
script.Parent.RemoteEvent3:FireServer()
end
end
end)
end)
External Media