So im making a script for a game and im new so i dont know this stuff but when i try to turn off my script instead of turning off it prints the turn off message but does not turn off can someone tell me why (@T3_MasterGamer help pls)
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local on = false script.Parent.MouseButton1Click:Connect(function() if on == false then print("turning on") repeat wait(1) on = true local part2 = Instance.new("Part", workspace) part2.CanCollide = false part2.Anchored = true part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 10)) part2.Name = "Part1" character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2) until on == false else on = false print("Turning off :(") game.Workspace:WaitForChild("Part2"):Destroy() script.Parent:Destroy() end end)
If it prints the message but doesn't do anything afterwards, the only answer is your WaitForChild call is infinitely yielding (it should print a warning in the console if stuck for too long, around 2 to 3 seconds). This means that the instance never appeared in the location you specified - check if you wrote the correct location and instance name.