#clickdetector issues when checking for boolvalue

69 messages · Page 1 of 1 (latest)

stuck escarp
#

basic stuff, havent scripted anything in a while

vocal storm
#

what is the problem lol

#

no ifo

#

info*

stuck escarp
#

the tween doesnt play

vocal storm
#

the second one?

stuck escarp
#

neither of the tweens play

#

the clickdetector is detecting clicks

vocal storm
#

clickdetect.MouseClick:Connect(function(player)
print("detected click")
opendoor()

end)

#

?

stuck escarp
#

i need it to check for a boolvalue that the player has

#

if the boolval == true then it does the function

#

and if it doenst nothing happens

vocal storm
#

yeah u already checking it on the function

stuck escarp
#

different value

#

the other boolval is checking if the door is open or not

#

the OpenDoors bool val means that the person can open doors

vocal storm
#

yeah i see and no tween play

#

could i see the Tweens?

#

how u declared it

stuck escarp
#

yup

#

i mean the tweens work without all the boolval checking

#

local Y = door.Position.Y
local X = door.Position.X
local Z = door.Position.Z


local boolval = script.Parent.Value
local clickdetect = script.Parent.Button.ClickDetector
local button = script.Parent.Button
local correctYposition = script.Parent.Position.Y


local minY = correctYposition - 1
local maxY = correctYposition + 10

local function clamp(value, min, max)
    return math.max(min, math.min(max, value))
end


local target = {
    Position = Vector3.new(X, clamp(Y + 8, minY, maxY), Z)
}
local target2 = {
    Position = Vector3.new(X, clamp(Y - 8, minY, maxY), Z)
}
local tweenService = game:GetService("TweenService")
local Tween = tweenService:Create(door, info, target)
local info2 = TweenInfo.new(2)
local Tween2 = tweenService:Create(door, info2, target2)

#

both tweens work

#

it tested it before i added all the boolval checks

#

idk if have my returns in the wrong spots or smth

vocal storm
#

could u print(boolval.Value) on the open door?

#

local function opendoor()
print(boolval.Value)
if boolval.Value == true then
Tween:Play()
print("opening door")
boolval.Value = false
button.BrickColor = BrickColor.new("Really red")
return

elseif boolval.Value == false then
    Tween2:Play()
    print("closing door")
    boolval.Value = true
    button.BrickColor = BrickColor.new("Lime green")
    return
end

end

stuck escarp
#

the "opening door" doesnt print

vocal storm
#

yeah thats why im telling u to print that

#

like this

#

clickdetect.MouseClick:Connect(function(player)
print("detected click")
print(boolval.Value)
local OpenDoors = player:WaitForChild("OpenDoors")
if OpenDoors.Value == false then
return
elseif OpenDoors.Value == true then
opendoor()
return
end

print()

end)

stuck escarp
#

alr

#

it prints

#

false

#

which is what its supposed to be

#

oh hol up

#

they swapped on the function

#

doesnt really do much tho

#

its not even getting to the function

vocal storm
#

then print OpenDoors.Value

stuck escarp
#

yeah but if waitforchild doesnt work usually u get the inf yield error

vocal storm
#

it gives and inf yield?

stuck escarp
#

no

vocal storm
#

then thats the problem lel

#

then just print it

stuck escarp
#

it printed

vocal storm
#

maybe is nil

stuck escarp
#

OpenDoors

#

let me try printing value

#

for some reason i cant print OpenDoors.Vector3

vocal storm
#

wut

#

what is OpenDoors

stuck escarp
#

a boolval assigned to the player

#

it prints "false" when printing its value

vocal storm
#

yeah thats the problem

#

when its false it just returns lol

#

check that out

stuck escarp
#

yeah hol up there is a second issue tho

#

even when its true it prints false

#

i mean the value for the variable shouldnt be set in stone bc i declare the variable in the clickdetect function

#

cause ik if you do local value = boolval.Value

#

then the value for that variable is set in stone

#

as soon as the script runs

#

so idk

stuck escarp
#

I added OpenDoors = player:WaitForChild("OpenDoors").Value to change the value to the correct one everytime the button is clicked

#

but it is still staying the same value

stuck escarp
#
clickdetect.MouseClick:Connect(function(player)
    print("detected click")
    local OpenDoors = player:WaitForChild("OpenDoors").Value

    if OpenDoors == false then 
        OpenDoors = player:WaitForChild("OpenDoors").Value
        return
    elseif OpenDoors == true then
        opendoor()
        print("finished function")
        OpenDoors = player:WaitForChild("OpenDoors").Value
        print(OpenDoors)
        return
    end
    

Why isnt this updating the opendoors value everytime its clicked?

#

i added a bunch of OpenDoors = player:WaitForChild("OpenDoors").Value to try to get it to update