I’m making a script where basically the player presses R, then everything unanchored on the map becomes anchored, including other players. Which works fine, but when they press R again to unanchor the recently anchored parts, it also works but it does not sync with what the other players see. Basically what I mean is, say another player jumps, then you press R. On your screen the player is frozen mid jump, but on the other players screen they are moving normally. Which is how I want it to work, but while that player is frozen mid jump, if you press R again instead of updating with the other players current position, it basically makes a clone of that player. Which just lands from the jump and stands there.
I was wondering how I could make it so when you toggle it off, other players and parts positions resync.
Heres the code
local AnchoredParts = {}
for _,ert in ipairs(workspace:GetDescendants()) do
if ert:IsA("Part") or ert:IsA("MeshPart") or ert:IsA("UnionOperation") and ert.Anchored == true then
table.insert(AnchoredParts, ert)
print("Inserted ", ert)
end
end
local BypassedParts = {}
for _,bps in ipairs(Character:GetDescendants()) do
if bps:IsA("BasePart") or bps:IsA("MeshPart") or bps:IsA("UnionOperation") then
table.insert(BypassedParts, bps)
table.insert(BypassedParts, HumanoidRootPart)
end
end
local FlashtimeParts = {}
--//Data
local FlashTime = false
--//Functions
function ToggleFlashtime()
if not FlashTime then
SpeedEvent:FireServer("Enable")
FlashTime = true
for _,anc in ipairs(workspace:GetDescendants()) do
if anc:IsA("Part") or anc:IsA("MeshPart") or anc:IsA("UnionOperation") then
if anc.Anchored == false and not table.find(BypassedParts, anc) then
table.insert(FlashtimeParts, anc)
anc.Anchored = true
print("Anchored", anc, "!")
end
end
end
elseif FlashTime then
FlashTime = false
print("Toggled Off!")
SpeedEvent:FireServer("Disable")
for _,unc in ipairs(workspace:GetDescendants()) do
if unc:IsA("Part") or unc:IsA("MeshPart") or unc:IsA("UnionOperation") then
if unc.Anchored == true and table.find(FlashtimeParts, unc) then
unc.Anchored = false
print("UnAnchored ", unc, "!")
end
end
end
end
end
Help would be appreciated.