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

Part (Hover, Click, Click, Colour)? [closed]

Asked by 5 years ago

(I do not know how to script at all, I need this script though) How would I do a script for when I hover over a part it changes to a certain color (Light Yellow) and then when I click on the part it changes to a certain color (Dark Yellow) Then when I click on it again and it's the Dark Yellow it then goes back to its original color and repeats the process of the Light Yellow > Dark Yellow > Original Color. Light Yellow (Hover) > Dark Yellow (Click) > Original Color (Click and checks if the color of the brick is Dark Yellow so that it can return to it's original color) ALSO, When you hover over it and then you all of a sudden don't hover over it, it turns back to its original color

0
This is for helping you solve problems. Not solving the problem for you. I'm not giving someone who doesn't even attempt to solve it, a script on this because it's quite simple. Learn through trial and error. Alphexus 498 — 5y
0
Well, Where can I get a script like that then? Trial and error is too time consuming and I'm not going to go on those stupid YouTube tutorials for basics of scripting. ApexStriker2 -6 — 5y

Closed as Not Constructive by cmgtotalyawesome, CaptainAlien132, Lugical, SuperSamyGamer, namespace25, and Fragmentation123

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
part = game.Workspace.Part
oldColor = part.BrickColor
mouse = game.Players.LocalPlayer:GetMouse()
yellow = BrickColor.new("New Yeller")
darkYellow = BrickColor.new("Br. yellowish orange")
mouse.Button1Down:Connect(function()
    if mouse.Target == part then -- Checking if the mouse is hovering over the part after clicking it
        if part.BrickColor == darkYellow then -- Check if the part's color is dark-yellow, if so, change it back to the original color
            part.BrickColor = oldColor
        elseif part.BrickColor == yellow then -- check if the part is yellow, if so, change it to dark yellow.
            part.BrickColor = darkYellow
        end
    end
end)
debounce = false
mouse.Move:Connect(function()
    if mouse.Target == part then -- Check if the mouse is hovering over the part
        if part.BrickColor == oldColor and not debounce then -- checking if the part is the original color, and checking if the mouse was off the part so it doesn't instantly change back to yellow.
            part.BrickColor = yellow
        end
        debounce = true
    else
        if part.BrickColor == yellow then --Checking if the part is yellow before changing it back to it's original color, so it doesn't change if it is orange.
            part.BrickColor = oldColor
        end
        debounce = false 
    end
end)

There you go. Hopefully this will teach you a thing or two about scripting. Enjoy!

0
If you're going to give someone a script for free at least explain what you're doing. Hes learning nothing and using this site for something that it wasn't intended for... cmgtotalyawesome 1418 — 5y
0
Alright. I'll update it to add some comments. Internal_1 344 — 5y
0
Guys! It's alright. I understand Lua very well, However I cannot apply my knowledge to when I am writing a script. That's why I find it so hard to actually write a script even though I understand clearly how scripts work. ApexStriker2 -6 — 5y
Ad