You shouldn't set variables to properties, because it simply reads the property and then sets the variable to the value of the property. (that's probably a little confusing...)
For example. If the Transparency property of game.Workspace.Part is 1 and I write a line like
t = workspace.Part.Transparency
print(t)
The output then prints out 1. The variable isn't game.Workspace.Part.Transparency, it simply read the value of that property and set the variable to that value.
THEREFORE, what you need is to set the variable to the object and then reference properties of the object.
Effectively, it should look more like this:
EquippedEvent.OnServerEvent:Connect(function(Player, Tool)
local C = Tool.HammerPart.HammerPart
while Tool.Parent == Player.Character do
while C.Color.r > 0 do
C.Color = Color3.new((C.Color.r-2)/255, C.Color.g/255, C.Color.b/255)
wait(0.01)
end
wait(0.1)
while C.Color.r < 255 do
C.Color = Color3.new((C.Color.r+2)/255, C.Color.g/255, C.Color.b/255)
wait(0.01)
end
wait(0.1)
end
end)
Also, I noticed while editing your code that you were going to get a weird result anyways since you forgot that when creating a new Color3 value you have to divide each rgb input by 255, since it looks for a number between 1 and 0 for each argument.
Hope this helps.
1 comment
Instead of color3.new, you can use color3.fromRBG to get the desired result without the division by 255