I cant seem to reproduce this behaviour with the code you provided so it must be something else in your game causing this. I also can’t see anything wrong with your code and when I test it the part is red. Are you sure this is the script causing the problem?
While I am here I will suggest a couple changes you could make to your script that are better practices:
-
Before defining any variables you should put
localbefore it. I can’t remember the technical details behind doing this but generally it is better. -
When using
Instance.new()you shouldn’t use the parent argument because doing this increases the amount of internal calls. Instead you should change all the necessary properties then parent the object as the last thing. You may want to read this thread for more information: PSA: Don't use Instance.new() with parent argument. Here is a code sample as well:
local Part = Instance.new("Part")
Part.Color = Color3.fromRGB(255, 0, 0)
Part.Size = Vector3.new(1, 1, 1)
Part.Parent = workspace -- Parents the part
- You should remove the
wait()at the beginning of your code because it is unnecessary. You should avoid usingwaitwhere you can because some developers have experienced incorrect or longer wait times when usingwait().