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

Why won't this change?

lastSpawn = nil
faces = script.Parent.Parent.Parent.Pants:GetChildren()--folder with lots of string values
Face = script.Parent.Parent.Parent.Dummy.Head.Face.Texture--face

script.Parent.MouseButton1Click:connect(function()
	
repeat
	
	curSpawn = faces[math.random(1,#faces)]
    
	until curSpawn ~= lastSpawn
       	
	lastSpawn = curSpawn

	wait() --Let the Character fully load

	Face = curSpawn.Value 

end)

So I have this gui and I am using 3D Module, I want to make a button that press like press the button face I want it to random generate a random face. So there isn't error showing up BUT the texture of the face doesn't change and also how can I make the 3D module change too.

1 answer

✓ Accepted answer

The reason it doesn't change is because you can't assign properties to variables. To fix this, you should change it to the following:

lastSpawn = nil
faces = script.Parent.Parent.Parent.Pants:GetChildren()--folder with lots of string values
Face = script.Parent.Parent.Parent.Dummy.Head.Face--face

script.Parent.MouseButton1Click:connect(function()

repeat

    curSpawn = faces[math.random(1,#faces)]

    until curSpawn ~= lastSpawn

    lastSpawn = curSpawn

    wait() --Let the Character fully load

    Face.Texture = curSpawn.Value 

end)


I'm not sure if there are any other errors with this, but I cannot see any.

Unfortunately, I am unable to help you with this '3D Module', however.

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