Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Players character resets online but not in studio?

Asked by
Chronomad 180
8 years ago

When I launch my game online and insert this script that replaces the players character into the PlayerScripts, after a few seconds, it resets the players character to its default and reloads the startergui. I can't find where it's going wrong. Thanks for any help!


wait(.1) local player while not player do wait() player = game:GetService('Players').LocalPlayer end function weld(p1,p2,c0) local w = Instance.new("Weld",p1) w.Part0 = p1 w.Part1 = p2 w.C0 = c0 or p1.CFrame:inverse() * p2.CFrame return w end function onSpawn() local char = game.ReplicatedStorage["New Player"]:Clone() local SpawnLocation = game.Workspace.SpawnLocation2 char.Parent = workspace char.Name = player.Name char:MoveTo(SpawnLocation.Position) local prevChar = player.Character wait() player.Character = char prevChar:Destroy() if char:FindFirstChild("Humanoid") then char.Humanoid:Destroy() end local human = Instance.new("Humanoid", char) char.Archivable = false human.WalkSpeed = 8 wait(1) human.Died:connect(function() wait(1) onSpawn() SetOutfit() wait(.01) player.Character.Humanoid.Running:connect(onGround) end) --Player Values local move_left = false local move_right = false local already_ran = false local grounded = false local idleAnimation = Instance.new("Animation") idleAnimation.AnimationId = "rbxassetid://317651678" local runningAnimation = Instance.new("Animation") runningAnimation.AnimationId = "rbxassetid://319211805" local R2 = Instance.new("Animation") R2.AnimationId = "rbxassetid://312976450" local I2 = Instance.new("Animation") I2.AnimationId = "rbxassetid://313623015" local J = Instance.new("Animation") J.AnimationId = "rbxassetid://326922088" function playAnimation(parent) local AnimTrack = player.Character.Humanoid:LoadAnimation(parent) AnimTrack:Stop() wait(.01) AnimTrack:Play() end function onGround(speed) if grounded == false then grounded = true end if speed > 1 and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Offensive") then if already_ran == false then already_ran = true playAnimation(runningAnimation) end elseif speed > 1 and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Idle") then if already_ran == false then already_ran = true playAnimation(R2) end elseif speed > 0 and already_ran == true and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Offensive") then already_ran = false playAnimation(idleAnimation) elseif speed > 0 and already_ran == true and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Idle") then already_ran = false playAnimation(I2) end end end onSpawn() player.Character.Humanoid.Running:connect(onGround) --SetOutfit() wait(0.5) PE.Parent = player.Character local SP = game.Lighting.SwordPlaySystemMK2:Clone() SP.Parent = player.PlayerGui SP.Disabled = false
0
Is this a localscript? BinaryResolved 215 — 8y
0
It is a localscript. I read that entry and will attempt to apply it . Chronomad 180 — 8y

Answer this question