Set colour based on stringvalue



I tried everything, but i still do not know how to set a part to change colour based on the string value, can anyone help?

1 Like

I don’t know why you’re using a StringValue, you could’ve use IntValue or NumberValue.

1 Like

I entered the script and haven’t seen any issue, you haven’t shown any script that sets the value of the “Speed” StringValue. Also don’t use a string for numbers.

1 Like

Why are you getting the speed from replicated storage when you can just make the variable in the script.

local speed = game:GetService("ReplicatedStorage"):WaitForChild("Speed")
--you can then just call speed.Value.
1 Like

Just might’ve noticed an issue in the first image

-- Your script
local speed = humanoidRootPart.Velocity.Magnitude
script.Parent = speed

-- Correct way
local speed = humanoidRootPart.Velocity.Magnitude
script.Parent.Value = speed
1 Like

Im going to have multiple parts (over 100) and thinking that instead of having it as a variable it will have better performance as a stringvalue (Which i now changed to a intvalue)

1 Like

Well a speed variable in the script is easier to get to than going to the game.ReplicatedStorage.Speed.Value 100 times.

1 Like


I added a print - print(speedValue.Value)
and realised that the number getting sent from the local script (Child of Numbervalue) is not getting sent to the numbervalue

1 Like

Try this and send a screenshot of what you get

print(typeof(speedValue))
1 Like

image

1 Like

What type of Script is used for the second piece of code? Is it a LocalScript or a server Script?

1 Like

Normal script for the longer script
Local script for the shorter one

Client-made changes to anything inside the ReplicatedStorage will not be sent to the server. Perhaps using just one server script to detect the player’s speed and change the part colour is a better option, although I’m not sure how exactly do you want your code to function.

Thanks! I needed to change the local script to a script and move the Numbervalue into workspace!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.