Help on a Rope script yes

while true do
    wait()
    if script.Parent.RopeConstraint.Attachment1 then
        if script.Parent.RopeConstraint.Attachment1.Changed then
            local RopeConstr = script.Parent.RopeConstraint
            local Player = game.Players:GetPlayerFromCharacter(RopeConstr.Attachment1.Parent.Parent.Parent)
            if Player.Character ~= nil then
                local MagnitudeInStuds = (script.Parent.Parent.Position - Player.Character.HumanoidRootPart.Position).Magnitude
                script.Parent.RopeConstraint.Length = math.round(MagnitudeInStuds) + 5
                print(math.round(MagnitudeInStuds))
                print(Player)
            end
        end
    end
end

Howdy I have an issue where the script works but when I unequip the tool it stops workings and gives me this error

17:48:26.218 Workspace.Texas style fire truck.Body.HoseGoodOk.Attachment.RopeScriptYes:7: attempt to index nil with 'Character' - Server - RopeScriptYes:7

Here is what the code is apposed to do

When you get the tool and start walking the rope length grows and then when you unequip it, it stops and the length goes back to 5, but when I do this all it does is stop the scripts so when I re-equip the tool it doesn’t work anymore

https://gyazo.com/4ade0ce5b4bff34794d07c045e436842