#This script, it causes lag when morphing the player and also the camera wont attach to the humanoid

1 messages · Page 1 of 1 (latest)

hexed cosmos
#

while true do
wait(10)
local message = Instance.new("Message")
message.Text = "Starting game!"
message.Parent = workspace
wait(1.5)
message:Destroy()

local players = game.Players:GetChildren()
if #players > 0 then
    local chosen = players[math.random(1, #players)]
    if chosen and chosen.Character then
        local nameo = chosen.KillerSkin:FindFirstChildOfClass("StringValue").Name
        local morph = game.ReplicatedStorage.SkinModels:FindFirstChild(nameo)
        if morph then
            local character = morph:Clone()
            character.Name = chosen.Name
            character.Parent = workspace
            chosen.Character = character

            local countdown = 25
            while countdown >= 0 do
                workspace.Round.TIMER.Value = countdown
                countdown = countdown - 1
                task.wait(1)
            end

            if chosen and chosen.Character then
                chosen.Character:BreakJoints()
            end
        end
    end
end

end

#

This script, it causes lag when morphing the player and also the camera wont attach to the humanoid

hexed cosmos
#

I've tried using remote events and local scripts but I just cant figure it out

zealous ibex
#

you have a wait(10) in your first function which delays the entire code for 10 seconds each time it cycles through

#

that's the "lag" you're experiencing. To fix this, use While task.wait(10) do

#

might want to check more frequently tho

#

and for the camera, havent got a clue as I have yet to work on coding with the camera, perhaps someone else knows, gl!

hexed cosmos
#

I was able to fix the camera myself by replacing the npcs humanoid with the players humanoid that way the camera subject doesnt have to switch to a new humanoid