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

Setting The Color3 Of A Tool Not Working?

Asked by
stef0206 125
5 years ago
Edited 5 years ago

I don't get any error code, but yet i seem to get a completely random output, here's my scripts;

Local Script Inside of Tool

script.Parent.Equipped:Connect(function()
    loop = true
end)

script.Parent.Unequipped:Connect(function()
    loop = false
end)

while wait(.1) do
    if loop == true then
        game.ReplicatedStorage.RemoteEvent:FireServer("ColorSword", 0)
    end
end

Script Inside ServerScriptService

local event = game:GetService("ReplicatedStorage").RemoteEvent

event.OnServerEvent:Connect(function(plr, event, value)
    if plr.Character:FindFirstChildOfClass("Tool") then
        x = 255
        y = 255
        z = 255
        if plr.leaderstats.Rep.Value > 0 then
            if plr.leaderstats.Rep.Value <= 100 then
                x = 255
                y = 255
                z = math.floor(255 / 100 * plr.leaderstats.Rep.Value)
            else
                x = 255
                y = 255
                z = 0
            end
        elseif plr.leaderstats.Rep.Value < 0 then
            if plr.leaderstats.Rep.Value >= -100 then
                x = 255
                y = math.floor(255 / 100 * (plr.leaderstats.Rep.Value * -1))
                z = math.floor(255 / 100 * (plr.leaderstats.Rep.Value * -1))
            else
                x = 255
                y = 0
                z = 0
            end
        else
            x = 255
            y = 255
            z = 255     
        end
    end
    print(x.." "..y.." "..z)
    plr.Character.ClassicSword.SwordColor.Value = Color3.new(x,y,z)
end)

Script Inside of Tool

while wait() do
    script.Parent.Handle.Color = script.Parent.SwordColor.Value
end

It might look a bit messy, but that's because I've tried mettling a bit around with it, It's supposed to change the color of a tool depending on a players leaderstat value, so -1 would be slightly red, and -100 or less would be completely red, positive numbers would result in Yellow, Please help me, and thank you.

EDIT: I decided to show what I meant with "random output" So my "Rep" stat is -50 the expected Color3 would be "255,127,127" And I get "65025, 32385, 32385" Im so confused, Please help!

1
Color3.fromRGB(0~255,0~255,0~255) arshad145 392 — 5y
1
Color3.new(0~1,0~1,0~1) arshad145 392 — 5y
0
So, you use Color3.fromRGB. arshad145 392 — 5y
0
Oh stef0206 125 — 5y
View all comments (2 more)
0
Thank you! stef0206 125 — 5y
0
You're welcome. arshad145 392 — 5y

Answer this question