The script below is suppose to change a STRING value string with “true” or “false”. The print(“yes”) works but it does not set the status to true/false
wait(1)
local status = game.Workspace.Door.DoorsOpen.Value
local e = script.Parent.WaitingTime
function onTouched(part)
if part.Name == "VehicleSeat" then
print("yes")
status = "true"
wait(e)
status = "false"
end
end
script.Parent.Touched:connect(onTouched)
This is an indirect change instead you should do it like this
wait(1)
local status = game.Workspace.Door.DoorsOpen
local e = script.Parent.WaitingTime
function onTouched(part)
if part.Name == "VehicleSeat" then
print("yes")
status.Value = "true"
wait(e)
status.Value = "false"
end
end
wait(1)
local status = game.Workspace.Door.DoorsOpen
local e = script.Parent.WaitingTime
status.Value = "true"
function onTouched(part)
if part.Name == "VehicleSeat" then
print("yes")
if status.Value == "true" then
wait(e)
status = "false"
if status.Value == "false" then
wait(e)
status.Value = "true"
print(" w")
end
end
end
end
script.Parent.Touched:connect(onTouched)
if the other one doesen´t work. i recomment trying this:
wait(1)
local status = game.Workspace.Door.DoorsOpen
local e = script.Parent.WaitingTime
status.Value = "true"
script.Parent.Touched:Connect(function(part)
if part.Name == "VehicleSeat" then
print("yes")
if status.Value == "true" then
wait(e)
status = "false"
if status.Value == "false" then
wait(e)
status.Value = "true"
end
end
end
end)
You are storing the value of DoorsOpen, which means that changing the variable’s data to “true” will not affect the DoorsOpen.Value, only the variable, since what you stored is not an object. Refer to @aliaun125’s post:
What you did was something like this:
local object = { Value = 0 }
local objectValue = object.Value
objectValue = 1
Printing the result of object.Value will still be 0. Instead it should be this:
That depends on the amount of seconds on the variable e, if the seconds is about 0.1 then you would hardly notice it. If that was not the case, then I have no idea what exactly caused it to not work; testing that on my end would obviously work without even trying; this is just basic common sense.
wait(1)
local status = game.Workspace.Door.DoorsOpen
local e = script.Parent.WaitingTime
script.Parent.Touched:Connect(function(part, hit)
status.Value = "true"
if hit and hit.Parent:FindFirstChild("Humanoid")
or part.Name == "VehicleSeat" then
print("yes")
if status.Value == "true" then
wait(e)
status = "false"
if status.Value == "false" then
print("no")
wait(e)
status.Value = "true"
end
end
end
end)
No, if the current object is not working, neither is the BoolValue. I made a little demo, and like I said before, it obviously works. The code is almost the same:
local status = script.Parent.Status
script.Parent.Touched:Connect(function()
status.Value = true
task.wait(10)
status.Value = false
end)
It could be because of the variable status that you are accessing which is game.Workspace.Door.DoorsOpen could be different from what you are lookng at. You did say that it does print “yes” on the terminal this must be the case.
wait(1)
local status = game.Workspace.Door.DoorsOpen.Value
local e = script.Parent.WaitingTime
script.Parent.Touched:Connect(function(part)
if part.Name == "VehicleSeat" then
print("yes")
status = "true"
else
wait(e)
status = "false"
end
end)