Problem with Module Script

  1. I Want to make a magical handcuff.
    The issue is that I Have no idea how to stop the cuffing function after I start, It will be working using a heartbeat.

I Will make a heartbeat connection run to handle the cuffed character, But I Do not know how to stop the cuffing of that character after it is cuffed, since I Am using a module script.

local RunService = game["Run Service"]

local Spells = {}

function Spells:Cuff(Player: Player, CuffedPlayer: Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local CuffedCharacter = CuffedPlayer.Character or Player.CharacterAdded:Wait()
	Player:SetAttribute("Casting", true)
	local Beam = script.Parent.Parent["Details."].Beam:Clone()
	Beam.Parent = Character.HumanoidRootPart
	local Attachment0 = Instance.new("Attachment")
	Attachment0.Parent = Character.HumanoidRootPart
	local Attachment1 = Instance.new("Attachment")
	Attachment1.Parent = CuffedCharacter.HumanoidRootPart
	Beam.Attachment0 = Attachment0
	Beam.Attachment1 = Attachment1
	
	
end

return Spells

save the connection to a variable, when it’s finished, call
variable:Disconnect()

saving a connection:
local variable = RunService.Heartbeat:Connect(yourFunction)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.