#clickdetector issues when checking for boolvalue
69 messages · Page 1 of 1 (latest)
the tween doesnt play
the second one?
clickdetect.MouseClick:Connect(function(player)
print("detected click")
opendoor()
end)
?
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
yeah u already checking it on the function
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
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
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
the "opening door" doesnt print
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)
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
then print OpenDoors.Value
yeah but if waitforchild doesnt work usually u get the inf yield error
it gives and inf yield?
no
it printed
maybe is nil
OpenDoors
let me try printing value
for some reason i cant print OpenDoors.Vector3
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
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
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