Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Join Morph Script not working?

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

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)

1 comment

0

Now that I read it, I'm not sure if I did this right.

This discussion is preserved as it was. New answers, comments, and votes are closed.