The script can't disable the rope constraint

my rope is bugging, The script can’t disable the rope constraint

local flyControls = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("FlyControls")

if not flyControls then
	warn("FlyControls not found!")
	
	return
end

local rope = script.Parent

if not rope then
	warn("RopeConstraint not found in Bed!")
	return
end


task.spawn(function()
	
	while true do
		if flyControls.f.Value == true then
			script.Parent.Enabled = false
		
		elseif flyControls.f.Value == false then
			script.Parent.Enabled = true
		end
		task.wait(0.1)
	end
end)

Where is the script located?? Are you getting any warnings or errors?

Also no need to make a separate thread for the while loop if nothing runs after it.

what’s the point of the rope variable then?

I am a beginner scripter, so I’m sorry if my script is goofy/weird
The local script is located in


and there’s no errors/warnings

script is local script? or server script?

it looks like you have a local script, redo it into a server script and everything will work correctly.

Hey, try this out. Make sure your script is on the server and check if the RopeConstraint is properly referenced. Here’s an example:

local flyControls = game.ReplicatedStorage:WaitForChild("FlyControls")

task.spawn(function()
    while true do
        if flyControls.f.Value then
            rope.Enabled = false
        else
            rope.Enabled = true
        end
        wait(0.1)
    end
end)
1 Like

thank you! it worked! you are a life saver!

1 Like

You’re very welcome! I’m so glad it worked

1 Like