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

Join Morph Script not working?

Asked by
Vividex 162
10 years ago

I am trying to make a script which gives me a certain hat and face when I join the game but before it does it removes my hat, I have the hats in the Workspace so when I join it changes there parents to my player, and for the face it changes my face texture ID. What I have so far:

local d = game.Workspace.Vividex
    for i=1, #d do
        if (d[i].className == "Hat") then
        d[i]:remove()
        end
    end
end

wait(1)

function OnPlayerEntered(player)
    if player.userId == 39704067 then
        game.Workspace["Clockwork Headphones"].Parent = Workspace.Vividex
        game.Workspace.WhiteTopHat.Parent = Workspace.Vividex
        game.Workspace["Ultra-Fabulous Hair Pink"].Parent = Workspace.Vividex
        game.Workspace.Vividex.Head.face.Texture = "http://www.roblox.com/asset/?id=26727653"
    end
end

game.Players.ChildAdded:connect(OnPlayerEntered)

but when I enter the game it makes the hats disappear and doesn't remove my hat, plus, I'm not sure when I reset the hats still stay on me. Please help?

1 answer

Log in to vote
0
Answered by 10 years ago

There's multiple errors:

repeat wait(1) until game.Workspace:findFirstChild("Vividex") -- makes sure you're there
local d = game.Players.Vividex.Character:GetChildren()
    for i=1, #d do
        if d[i].ClassName == "Hat" then
        d[i]:remove()
        end
    end
 -- One too many ends here.

wait(1)

function OnPlayerEntered(player)
    if player.userId == 39704067 then
        game.Workspace["Clockwork Headphones"].Parent = workspace.Vividex
        game.Workspace.WhiteTopHat.Parent = workspace.Vividex
        game.Workspace["Ultra-Fabulous Hair Pink"].Parent = workspace.Vividex
        game.Workspace.Vividex.Head.face.Texture = "http://www.roblox.com/asset/?id=26727653"
    end
end

game.Players.ChildAdded:connect(OnPlayerEntered)
0
Now that I read it, I'm not sure if I did this right. hievery1 70 — 10y
Ad

Answer this question