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

Random Face on Death Script?

Asked by 7 years ago
local ContentProvider = game:GetService("ContentProvider")
repeat wait() until game.Players.LocalPlayer.Character ~= nil
repeat wait() until (ContentProvider.RequestQueueSize == 0)

local Plr = game.Players.LocalPlayer
local Char = game.Players.LocalPlayer.Character
while true do
    wait(0.1)
    if script.Parent.Humanoid ~= nil then
        if script.Parent.Humanoid.Health ==1 then
local ChangeFace = true
local FaceId = {574701104, 574701264, 574701296, 574701328, 574701359, 574701387, 574701414, 574701431, 574701479, 574701532}

wait(0.5)

if ChangeFace then
local var = FaceId[math.random(1,#FaceId)]

Char:WaitForChild("Head").face.Texture = ("http://www.roblox.com/asset/?id=" .. var)
end
wait(0.1)
            script:remove()
        end
    end
end

I don't know what is up with this script. I've tried everything I could... Is there something that needs to be changed? Thanks!

Also, which type of script should I put this in? Script? Local Script?

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago

This looks like an old, dangerous script. Since it uses LocalPlayer and ContentProvider then it would be a LocalScript. I would rewrite it to be serverside though, because I don't know if the face would replicate with filtering.

Here are some problems:

-Uses ContentProvider for seemingly no reason

-Uses LocalPlayer for no reason

-Only works in the rare case your health is 1

-Unnecessary loops and waits

-Uses remove()

Lastly the face texture idea is quite smart but you might look into PreLoading.

--Script in StarterCharacterScripts
local char = script.Parent

local FaceId = {574701104, 574701264, 574701296, 574701328, 574701359, 574701387, 574701414, 574701431, 574701479, 574701532}

local id= FaceId[math.random(#FaceId)]

char:WaitForChild("Humanoid").Died:wait()

char.Head.face.Texture = "http://www.roblox.com/asset/?id=" .. id
script:Destroy()
Ad

Answer this question