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

Why doesn't this change texture?

This script is suppose to check the value of something when its changed, and change the texture of a decal depending on the number after the value was changed. If this makes any sense and you can help me, here is the code. Nothing shows up in the output.

-- Made by AwsomeSpongebob
Face = script.Parent.Face.Texture
FaceValue = script.Parent.Value
FaceVal = FaceValue.Value

FaceValue.Changed:connect(function()
	if FaceVal == 0 then
		Face = ("rbxasset://textures/face.png")
	elseif FaceVal == 1 then
		Face = ("http://www.roblox.com/asset/?id=26434948")
	elseif FaceVal == 2 then
		Face = ("http://www.roblox.com/asset/?id=13079565")
	elseif FaceVal == 3 then
		Face = ("http://www.roblox.com/asset/?id=29291814")
	elseif FaceVal == 4 then
		Face = ("http://www.roblox.com/asset/?id=69252500")
	elseif FaceVal == 5 then
		Face = ("http://www.roblox.com/asset/?id=25553966")
	elseif FaceVal == 6 then
		Face = ("http://www.roblox.com/asset/?id=28440649")
	elseif FaceVal == 7 then
		Face = ("http://www.roblox.com/asset/?id=21439548")
	elseif FaceVal == 8 then
		Face = ("http://www.roblox.com/asset/?id=69714134")
	elseif FaceVal == 9 then
		Face = ("http://www.roblox.com/asset/?id=149124698")
	elseif FaceVal == 10 then
		Face = ("http://www.roblox.com/asset/?id=31142001")
	elseif FaceVal == 11 then
		Face = ("http://www.roblox.com/asset/?id=112805849")
	end
end)

1 answer

✓ Accepted answer

There are three lines, that I can see with your script is that the Values at the top of the script are out of order here is a fixed version of your script:

-- Made by AwsomeSpongebob, and fixed by Darkness246810
Face = script.Parent:WaitForChild('Face') -- Wait for things!
FaceVal = script.Parent:WaitForChild('Value') -- Wait for things!

FaceValue.Changed:connect(function()
    if FaceVal.Value == 0 then -- It is best do it this way!
        Face.Texture = ("rbxasset://textures/face.png") -- Same Here!
    elseif FaceVal.Value == 1 then
        Face.Texture = ("http://www.roblox.com/asset/?id=26434948")
    elseif FaceVal.Value == 2 then
        Face.Texture = ("http://www.roblox.com/asset/?id=13079565")
    elseif FaceVal.Value == 3 then
        Face.Texture = ("http://www.roblox.com/asset/?id=29291814")
    elseif FaceVal.Value == 4 then
        Face.Texture = ("http://www.roblox.com/asset/?id=69252500")
    elseif FaceVal.Value == 5 then
        Face.Texture = ("http://www.roblox.com/asset/?id=25553966")
    elseif FaceVal.Value == 6 then
        Face.Texture = ("http://www.roblox.com/asset/?id=28440649")
    elseif FaceVal.Value == 7 then
        Face.Texture = ("http://www.roblox.com/asset/?id=21439548")
    elseif FaceVal.Value == 8 then
        Face.Texture = ("http://www.roblox.com/asset/?id=69714134")
    elseif FaceVal.Value == 9 then
        Face.Texture = ("http://www.roblox.com/asset/?id=149124698")
    elseif FaceVal.Value == 10 then
        Face.Texture = ("http://www.roblox.com/asset/?id=31142001")
    elseif FaceVal.Value == 11 then
        Face.Texture = ("http://www.roblox.com/asset/?id=112805849")
    end
end)
  • This should work!

4 comments

0

Thanks!But why use WaitForChild instead of just telling it where it is?

0

Like using script.parent.value?

0

The value might not have loaded when you try to find it!

0

Oh ok. Thanks! :D

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