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

Why isn't this script working?

The script it supposed to change my texts color to blue, wait a second, then change back to white. and this error pops up:

"attempt to perform arithmetic on field 'TextColor3' (a userdata value)" I have no idea what that means, here is the script:

while true do
for i = 1,10 do
	wait()
	script.Parent.TextColor3 = script.Parent.TextColor3 - Color3.new(0.1,0.1,0)
end
wait(1)
for i = 1,10 do
	wait()
	script.Parent.TextColor3 = script.Parent.TextColor3 + Color3.new(0.1,0.1,0)
end
end

The TextColor is already white

1 answer

✓ Accepted answer

The error means that there is no set metatable to perform mathematical operations on that userdata (Color3).

You need to do it like this (get the individual numbers):

while true do
	for i = 1,10 do
	    wait()
	    script.Parent.TextColor3 = Color3.new(script.Parent.TextColor3.r - .1,script.Parent.TextColor3.g - .1,0)
	end
	wait(1)
	for i = 1,10 do
	    wait()
	    script.Parent.TextColor3 = Color3.new(script.Parent.TextColor3.r + .1,script.Parent.TextColor3.g + .1,0)
	end
end

2 comments

0

thanks, but it's yellow :b

0

nvm i fixed it, the script set the textcolor to 1,1,0

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