I made some code in Filtering Enabled which requires a while loop needed to update a part's position every .1 second. But of course when I'm running the loop, the rest of the code doesn't run which is a problem. Help? I could make another script to loop it but the main script still needs the variable because its F.E.
This is what is in the script: (The while loop is commented)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player,mouse,anim,Jailed,Jailed2,Hit,isCaught)
--local Jailed1 = Instance.new("Part",Player.Character)
--Jailed1.Transparency = 1
--Jailed1.Anchored = true
--Jailed1.CanCollide = false
--Jailed1.Name = ("Here")
--while true do
--Jailed1.CFrame = Player.Character.Torso.CFrame
--wait(.1)
print("hi")
local Jailed1 = Player.Character.Tool.Handle
local attachmentB = Instance.new("Attachment",Jailed2)
local attachmentA = Instance.new("Attachment",Jailed1)
attachmentA.Position = Vector3.new(1,-0.7,0.3)
attachmentB.Position = Vector3.new(0,0,0.3)
print("hi")
local ropeConstraint = Instance.new("RopeConstraint",Jailed1)
ropeConstraint.Attachment0 = attachmentA
ropeConstraint.Attachment1 = attachmentB
ropeConstraint.Length = 10
ropeConstraint.Visible = true
ropeConstraint.Color = BrickColor.Black()
ropeConstraint.Thickness = 0.2
ropeConstraint.Restitution = 0.5
local caught = Jailed.Humanoid:LoadAnimation(anim)
caught:Play()
script.Parent.Unequipped:Connect(function()
ropeConstraint:Destroy()
attachmentA:Destroy()
attachmentB:Destroy()
caught:Stop()
isCaught = false
end)
end)

1 comment
Not that it matters with your particular question but this is terrible framework for work in FE as you've only set the event up to deal with one type of communication within the game. Check this video out it might help: https://www.youtube.com/watch?v=m_CsACgDwOM