So as I have mentioned in a few posts I’ve been working on a JoJo game, in this I was making a time skip script when I came across an issue. The player’s position updates properly for all clients present when it’s used, however server side (and for any clients that join after it’s used) it disconnects the HumanoidRootPart from the rest of the body. I have tried several solutions but they all leaded to the player’s character getting messed up server side. Here’s my code:
local Event = game.ReplicatedStorage.MoveUse.TimeSkip
local Cooldown = 30
local Distance = 40
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(Player)
local UsingTS = Instance.new("BoolValue")
UsingTS.Name = "UsingTimeSkip"
UsingTS.Parent = Player
UsingTS.Value = false
end)
Event.OnServerEvent:Connect(function(Player)
local Char = Player.Character
local UsingTS = Player.UsingTimeSkip
local IsTSed = Player.Character.PlayerWhoTS
local UsingTimeStop = Player.TSInEffect
local IsBD = Char.IsBeingBD
if IsTSed.Value == 0 and IsBD.Value == 0 then
if UsingTS.Value == false and UsingTimeStop.Value == false then
local Descendants = Char:GetDescendants()
for i in pairs(Descendants) do
local IsPart = Descendants[i]:IsA("Part")
local IsMesh = Descendants[i]:IsA("MeshPart")
if IsMesh == true or IsPart == true then
Descendants[i].Anchored = true
end
end
UsingTS.Value = true
local Root = Char:WaitForChild("HumanoidRootPart")
local Sound = Root:WaitForChild("TW, TS")
Sound.TimePosition = 2
Sound:Play()
local cf = Root.CFrame
cf = cf + cf.LookVector * Distance
Root.Position = cf.Position
wait(0.01)
for i in pairs(Descendants) do
local IsPart = Descendants[i]:IsA("Part")
local IsMesh = Descendants[i]:IsA("MeshPart")
if IsMesh == true or IsPart == true then
Descendants[i].Anchored = false
end
end
end
wait(Cooldown)
UsingTS.Value = false
print(UsingTS.Value)
end
end)