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

Help with my Keycard Script?

Asked by 9 years ago

This script doesn't work, but it has no errors. Read the message in the script.

function onClicked()
    if character.PlayerTouched("Keycard")--If the player touches a part or union operation that is called "Keycard"     
        then --Then the door, if you have touched "Keycard", then it enables the script in the door that makes it open. 
        script.Parent.DoorScript.Disabled = false
        script.Parent.Panel1.ScreenGUI.Frame.BrickColor.BrickColorNew = ("NeonGreen")
        script.Parent.Panel1.ScreenGUI.Frame.BrickColor.BrickColorNew = ("NeonGreen")
    end
end


























--[[Obviously, "NeonGreen" wouldn't work, I know it's in the (0,0,0) setup,
    but I have no clue how to do that. If someone could help me fix this script,
    that'd be very helpful, and I will put you in my game's credits.
    Also, I know you need values, and such like a "True" or "False" bool value,
    I think. But I'm not advanced enough to do that. Also, it's amazing
    this has no errors, considering it does absolutely NOTHING. lol
    Also, the Keycard will be a UnionOperation, as well, if that factors into
    anything.

    Also, what I was trying to get in the script, is where it stays red until
    you click "Panel" which is where the SurfaceGUI is, IF you have touched
    "KeyCard."
]]

2 answers

Log in to vote
1
Answered by
RoboFrog 400 Moderation Voter
9 years ago

Oh, where to start...

To fix your color issue, you can do this --

(0/255, 0/255, 0/255)

And use a site such as this and use the R, G, and B components in that order. That will then give you the desired color.

Your function isn't being called upon from anywhere, it's just a function. What you should be doing is this --

script.Parent.ClickDetector.MouseClick:connect(function(hit) -- script.Parent is the script's parent, you must have a click detector in the clicked block, and you must connect the function. "hit" is what the function returns when clicked, in this case, the player's character.
    -- Put your code here!
end)

In your example, character isn't referencing anything, it's just an unstated variable. Originally, character was probably the return from the function you got this code from. In the case of the example above, hit is the equivalent of character.

As for whatever the PlayerTouched stuff is, use a Touched event instead. Documentation/an example can be found here.

The rest of the help I can give would be making the script for you. That isn't what this site is about. If you have any other questions, feel free to ask and I'll do my best to help.

Ad
Log in to vote
0
Answered by 9 years ago

You can't use .BrickColorNew. To fix this, you can use this:

script.Parent.Panel1.ScreenGUI.Frame.BrickColor = BrickColor.new("Bright green")

Also, .PlayerTouched is not an event. You would have to add a .Touched event in the slot for the keycard, then test which brick touches it for if it matches the Keycard qualifications.

0
Slight typo, you've got "BrickColor,new" instead of "BrickColor.new". Nothing major, I just felt it was worth clearing up. RoboFrog 400 — 9y
0
Ah, yes, sorry. How ironic, lol. SlickPwner 534 — 9y

Answer this question