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

Why does the event not fire in my colour wheel script?

Asked by 3 years ago

I am a rather new developer and sometimes use other people's scripts. I tried making a color wheel edit the baseplate on the server but it's being weird and I have no idea why.

Local Script inside the GUI:

local dragger = require(script:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl"));

local slider = script.Parent:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl1")
local slide = slider:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl")

local wheel = script.Parent:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl2");
local ring = wheel:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl");

local colour = script.Parent:WaitForChild("IllllIlIIIlIllIllllIIIIlIlIIllIIllllIIIl3");

--

local function toPolar(v)
    return math.atan2(v.y, v.x), v.magnitude;
end

local function radToDeg(x)
    return ((x + math.pi) / (2 * math.pi)) * 360;
end

--

local hue, saturation, value = 0, 0, 1;

local function update()
    colour.BackgroundColor3 = Color3.fromHSV(hue, saturation, value);
    game:GetService("ReplicatedStorage").Remotes.Events.obfuscatedRemote:FireServer("Color", Color3.fromHSV(hue,saturation,value), workspace.StartingPlate)
end

-- dragger

local slideDrag = dragger.new(slide);
local ringDrag = dragger.new(ring);

function slideDrag:onDrag(guiElement, input, delta)
    local rY = input.Position.y - slider.AbsolutePosition.y;
    local cY = math.clamp(rY, 0, slider.AbsoluteSize.y - slide.AbsoluteSize.y);
    guiElement.Position = UDim2.new(0, 0, 0, cY);

    value = 1 - (cY / (slider.AbsoluteSize.y - slide.AbsoluteSize.y));
    guiElement.BackgroundColor3 = Color3.fromHSV(0, 0, 1-value);

    update();
end

function ringDrag:onDrag(guiElement, input, delta)
    local r = wheel.AbsoluteSize.x/2
    local d = Vector2.new(input.Position.x, input.Position.y) - wheel.AbsolutePosition - wheel.AbsoluteSize/2;

    if (d:Dot(d) > r*r) then
        d = d.unit * r;
    end

    guiElement.Position = UDim2.new(0.5, d.x, 0.5, d.y);

    local phi, len = toPolar(d * Vector2.new(1, -1));
    hue, saturation = radToDeg(phi)/360, len / r;
    slider.BackgroundColor3 = Color3.fromHSV(hue, saturation, 1);

    update();
end

Server script:

obfuscatedRemote.OnServerEvent:Connect(function(player, typo, otherValue, targetedObj)
    if typo == "Color" then
        local work = workspace:GetDescendants()
        if work:FindFirstChild(targetedObj) then
            targetedObj.Color = Color3.fromHSV(otherValue)
        else
            warn("The targeted obj does not exist.")
        end
    end
end)

I tried doing all the ways I could think of, removing and adding those semi-colins, adding another local function but nothing worked, only the colour.BackgroundColor3 changed.

Answer this question