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

Why isn't this script working?

Asked by 10 years ago

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

Log in to vote
1
Answered by
MrNicNac 855 Moderation Voter
10 years ago

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

0
thanks, but it's yellow :b Senor_Chung 210 — 10y
0
nvm i fixed it, the script set the textcolor to 1,1,0 Senor_Chung 210 — 10y
Ad

Answer this question