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

My click button door wont work but it says there are no errors. Idk what to do. can u help meh plz?

Asked by 7 years ago

i've been trying to make a click button door but every time I do it, it wont work but it shows no errors. what I want it to do is when you click the door the door cancollie = true and the image transparency = 1. and when you click it again the door cancollide = false and the image transparency = 0. this is te script:

function OnClicked (mousebutton1) script.parent.image.transparency = 1 script.parent.CanCollide = true

if
    script.parent.ClickDetector == true then
    script.parent.image.transpatency = 0
    script.parent.CanCollide = false
end

end


0
it got messed up here is the script: OfficalIrishArmy 15 — 7y
0
function OnClicked (mousebutton1) script.parent.image.transparency = 1 script.parent.CanCollide = true if script.parent.ClickDetector == true then script.parent.image.transpatency = 0 script.parent.CanCollide = false end end OfficalIrishArmy 15 — 7y
0
You're not calling the function User#11440 120 — 7y

3 answers

Log in to vote
1
Answered by
yut640 91
7 years ago
Edited 7 years ago

Here's a really simple working script make sure you set it up like this

  1. Put script inside of block

  2. Add a click detector inside of block

  3. Add a boolvalue with the name "Value" inside of block

Script:

B = script.Parent.Value.Value -- checks for the value of value lol

function CanCollide()

    if B == true then B = false --When it's false it is like this (default cancollide and not transparent)
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true


    else
        B = true -- after clicking (for first time)
        script.Parent.Transparency = 1 -- change to whatever you want
        script.Parent.CanCollide = false
    end

end

script.Parent.ClickDetector.MouseClick:connect(CanCollide) -- make sure this is correct (ClickDetector) --





If you need any help let me know! Make sure that you accept my answer if it works :)

Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

First of all, if you don't already have one, create a ClickDetector inside of your button part. A ClickDetector is a Roblox instance that you put in a part, and it waits for a player to click that part. You also need to call it inside of your script

local clicker = part.ClickDetector --assuming part is defined

Secondly, you need to call your function, as wfvj014 stated. You can do that with the MouseClick event like so

local door = script.Parent
local ImageTransparency = script.Parent.image.Transparency
local clicker = part.ClickDetector --assuming part is defined

function onClicked(mousebutton1)
   if ImageTransparency == 1 then
        ImageTransparency = 0
        door.CanCollide = true
    end
    if ImageTransparency == 0 then
        ImageTransparency = 1
        door.CanCollide = false
    end
end

clicker.MouseClick:connect(onClicked)

Another thing I noticed is that you have an unused mousebutton1 parameter for your function. I don't know if you will use it later, so I left it there.

Hope this fixes your problem --connor12260311

Log in to vote
-1
Answered by 7 years ago

Try this

local door = script.Parent
local ImageTransparency = script.Parent.image.Transparency

function onClicked(mousebutton1)
    if ImageTransparency == 1 then
        ImageTransparency = 0
        door.CanCollide = true
    end
    if ImageTransparency == 0 then
        ImageTransparency = 1
        door.CanCollide = false
    end
end

Tell me if you get any errors Accept this answer if it worked leave a comment if it didn't. :D

0
You're suppose to explain your answer. User#11440 120 — 7y

Answer this question