so basically im making a custom character script, that replaces the player's character with my own model. The problem im having is my script only works for like 5 second before turning the character back to normal. How would i keep this permanent? This is located inside of player starter scripts. Its also a module script inside this script
wait(1)
local player
while not player do
wait()
player = game:GetService('Players').LocalPlayer
end
--local face = player.Character.Head.face:Clone()
function onSpawn()
local char = game.ReplicatedStorage.CustomCharacter:Clone()
--local SpawnLocation = game.Workspace.SpawnLocation
--face.Parent = char.Head
char.Parent = workspace
char.Name = player.Name
--char:MoveTo(SpawnLocation.Position)
--[[for _,v in pairs(char:GetChildren()) do
v.BrickColor = BrickColor.new("Deep blue")
end]]--skin color
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.Died:connect(function()
wait(1)
onSpawn()
wait(.1)
player.Character.Humanoid.Running:connect(whenRunning)
player.Character.Humanoid.Jumping:connect(whenJumping)
player.Character.Humanoid.FallingDown:connect(whenFalling)
player.Character.Humanoid.FreeFalling:connect(whenFalling)
end)
local character = char
local animTbl = require(script.Animations)(character, character.Humanoid)
--Remove prints if they lag
local onGround = true
local prevAirType = 'grounded'
local inAirType = 'grounded'
local canPlayIdle = true
local canPlayWalk = false
local canPlayJump = false
local canPlayFall = false
function whenRunning(speed)
prevAirType = inAirType
inAirType = 'grounded'
onGround = true
if speed > 1 then
canPlayIdle = true
if canPlayWalk == true then
canPlayWalk = false
print("walk")
animTbl:stop('idle', character.Humanoid)
animTbl:play('walk', character.Humanoid)
end
else
canPlayWalk = true
if canPlayIdle == true then
canPlayIdle = false
print("idle")
animTbl:stop('walk', character.Humanoid)
animTbl:play('idle', character.Humanoid)
end
end
end
function whenFalling()
prevAirType = inAirType
inAirType = 'fall'
onGround = false
end
function whenJumping()
prevAirType = inAirType
inAirType = 'jump'
onGround = false
end
character.Humanoid.Running:connect(whenRunning)
character.Humanoid.FreeFalling:connect(whenFalling)
character.Humanoid.Jumping:connect(whenJumping)
end
onSpawn()
player.Character.Humanoid.Running:connect(whenRunning)
player.Character.Humanoid.Jumping:connect(whenJumping)
player.Character.Humanoid.FallingDown:connect(whenFalling)
player.Character.Humanoid.FreeFalling:connect(whenFalling)

2 comments
yea but the animations wouldnt load into the character >.>
what do you mean