Whenever I use a toggle command script to disable and enable this script, it always works with people who recently join AFTER the script is enabled. The toggle command script works, but the other script doesn't work post-enabling.
The toggle command loads the character after the toggling, which should cause the parts to spawn inside the torso, but they don't. The issue is that they spawn for newer players who join after the command turns the script on.
Here's the script I currently have that gets toggled:
P.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild'Humanoid' local Torso = Character:WaitForChild'Torso' local TouchedTable = { {'TopRight', false, CFrame.new(Size.X/2, Size.Y/2, -Size.Z/2)}; {'TopRight', false, CFrame.new(Size.X/2, Size.Y/2, -Size.Z/2)}; {'BottomRight', false, CFrame.new(-Size.X/2, Size.Y/2, Size.Z/2)}; {'BottomRight', false, CFrame.new(-Size.X/2, Size.Y/2, Size.Z/2)}; } local Flinging = false local Swimming = false local function Weld(Part0, Part1, C0, Parent) local W = Instance.new('Weld', Parent) W.Part0 = Part0 W.Part1 = Part1 W.C0 = C0 end local function getSurface(position, object) local surfaces = { back = object.CFrame * CFrame.new(0, 0, object.Size.Z); front = object.CFrame * CFrame.new(0, 0, -object.Size.Z); top = object.CFrame * CFrame.new(0, object.Size.Y, 0); bottom = object.CFrame * CFrame.new(0, -object.Size.Y, 0); right = object.CFrame * CFrame.new(object.Size.X, 0, 0); left = object.CFrame * CFrame.new(-object.Size.X, 0, 0); } local surface = "back" for side, cframe in pairs (surfaces) do surface = ((position - cframe.p).magnitude > (position - surfaces[surface].p).magnitude and surface or side) end return surface end local function Fling(Hit) if (TouchedTable[1] or TouchedTable[2]) and not (Flinging) then Flinging = true local Direction local Surface = getSurface(Torso.Position, Hit) if (Surface == 'front') then Direction = Hit.CFrame.lookVector * 500 elseif (Surface == 'back') then Direction = Hit.CFrame.lookVector * -500 elseif (Surface == 'right') then Direction = Hit.CFrame.rightVector * 500 elseif (Surface == 'left') then Direction = Hit.CFrame.rightVector * -500 elseif (Surface == 'top') then Direction = Hit.CFrame.upVector * 500 elseif (Surface == 'bottom') then Direction = Hit.CFrame.upVector * -500 end local Force = Instance.new('BodyVelocity') Force.MaxForce = Vector3.new(40000, 0, 40000) Force.P = 99999 Force.Velocity = Direction Force.Parent = Torso wait(VelocityTime[math.random(1, #VelocityTime)]) Force:Destroy() wait(FlingAgainWait) Flinging = false end end Humanoid.StateChanged:Connect(function(old, new) if (new == Enum.HumanoidStateType.Swimming) then if not (Swimming) then Swimming = true end else if (Swimming) then Swimming = false end end end) for _ = 1, 4, 1 do local PClone = Part:Clone() PClone.Parent = Torso PClone.Name = TouchedTable[_][1] Weld(Torso, PClone, TouchedTable[_][3], Torso) PClone.Touched:Connect(function(h) if (h.ClassName ~= 'Part') or (h == Torso) or (h.Parent == Character) or (h.Parent.Parent == Character) or (h.CanCollide == false) or (Humanoid.Health <= 0) or (Swimming) or (Flinging) or (game.Players:GetPlayerFromCharacter(h.Parent)) or (game.Players:GetPlayerFromCharacter(h.Parent.Parent)) then return end if not (TouchedTable[_][2]) then TouchedTable[_][2] = true Fling(h) wait(PartDebounceWait) TouchedTable[_][2] = false end end) end end) end)