Roblox ScreenGUI problems - roblox

I was wondering if there was a thing that I had to do in order to change the text of a GUI mid-game. Because my problem is that I'm making a timer that goes through "Round in progress", "Game Over", "Intermission", "Voting in progress," and then repeat forever. But the text itself gets stuck on Round In Progress. Throughout the timer, the text value in the properties of the label changes, but the text doesn't change on the screen GUI
I've been changing the text with the same method every time:
status.Text = "Game over"
then I'd have the timer go about 5 seconds before I change it again:
status.Text = "Intermission"
And so on in a loop...
This is the whole code:
local rep = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local minutesvalue = rep:WaitForChild("Minutes")
local secondsvalue = rep:WaitForChild("Seconds")
local minutes = 0 --minutes
local seconds = 11 --seconds
local status = game.StarterGui.Status:WaitForChild("Status")
while true do
status.Text = "Round In Progress"
minutesvalue.Value = minutes
secondsvalue.Value = seconds
repeat
if secondsvalue.Value <= 0 then
minutesvalue.Value = minutesvalue.Value - 1
secondsvalue.Value = 59
else
secondsvalue.Value = secondsvalue.Value - 1
end
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
status.Text = "Game Over!"
wait(5)
status.Text = "Intermission"
secondsvalue.Value = 15
repeat
secondsvalue.Value = secondsvalue.Value - 1
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
status.Text = "Voting In Progress"
secondsvalue.Value = 10
repeat
secondsvalue.Value = secondsvalue.Value - 1
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
status.Text = "Loading Map..."
end
The Timer and the Status are separate GUIs.
I separated it in the hope that it would work, but it didn't.

It's because you're doing it in the StarterGui, I'm sure, do it in the players PlayerGui so replace:
local status = game.StarterGui.Status:WaitForChild("Status")
with:
local status = players[plr].PlayerGui:WaitForChild("Status")
(Define plr)

Related

dht11 sensor only retuning unexpected number of pulse often

I am trying to make a simple water pump controller using a dth11 to make the pump turn on more frequently when the temperature is higher. i have it working but every 4th or 5th time i call measure on the dht11 sensor i get an error saying "InvalidPulseCount: Expected 82 but got 0 pulses" or "InvalidPulseCount: Got more than 82 pulses". I have added try block that is stopping the program from crashing but would really like to figure out why it is happening. I also had to edit the dht.py lib to have 82 instead of 84 as the default expected pulses because that was what was commonly returned.
here is my main.py file
from machine import Pin
from time import sleep_ms
import dht
import I2C_LCD_driver
sensor = dht.DHT11(Pin(28))
lcd = I2C_LCD_driver.lcd()
pump = Pin(7, machine.Pin.OUT)
counter = 0
pumpTime = 30
normalTime = 60
hotTime = 30
lowTemp = 19
# sensor variables only updated every 3 loops
lastMesure = 1
temp = 0
humid = 0
first = True
while True:
# sensor.messure can only be called ever 3 seconds
# start at 1 and set to zero in the first loop for our first messurement
lastMesure += -1
if lastMesure <= 0:
try:
sensor.measure()
lastMesure = 3
temp = round((sensor.temperature), 0)
humid = sensor.humidity
except:
print("something went wrong")
print("Counter: {:.0f} pumpping:{:0.f}".format(counter, pump.value()))
print("Temp: {:.0f}℃ HUMIDITY: {:.0F}% ".format(temp, humid))
# if the pump is running
if pump.value() == 1:
if counter >= pumpTime: # if it has been the set pump run time
pump.value(0) # turn off pump
counter = 0 # reset counter
else:
counter += 1
else:
# check current temp
# if warmer then {lowTemp} check for {hotTime} else check for {normalTime}
if (temp > lowTemp and counter >= hotTime) or counter >= normalTime:
pump.value(1) # turn on pump
counter = 0 # reset counter
else:
counter += 1
# print current data to the screen
lcd.lcd_clear()
lcd.lcd_display_string("T: {:.0f}C H:{:.0f}%".format(temp, humid), 1)
if pump.value() == 1:
status = f'Pumping {pumpTime - counter}s'
lcd.lcd_display_string(status, 2);
else:
lcd.lcd_display_string("Pump off ", 2)
sleep_ms(1000)
here is a picture of my breadboard set up. I have run it both with and without a 1k pull up resistor on the data pin

Infinite leaderstat Abbreviating

I own a simulator with 0 active that has Clicks. When I upgrade too much, my clicks get negative amount of clicks at a few quintillions (10^18), abbreviations work until decillions. (10^33). How do I make that clicks will not turn negative or something else wrong will happen with their value when I reach over a few quintillions?
Leaderstats Script (game.Workspace):
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("IntValue",plr)
leaderstats.Name = "leaderstats"
local Clicks = Instance.new("IntValue",leaderstats)
Clicks.Name = "Clicks"
local Power = Instance.new("IntValue",leaderstats)
Power.Name = "Power"
Power.Value = 1
local SC = Instance.new("IntValue",leaderstats)
SC.Name = "SuperClicks"
local MC = Instance.new("IntValue",leaderstats)
MC.Name = "MegaClicks"
local SCC = Instance.new("IntValue",leaderstats)
SCC.Name = "SuperClicksChance"
SCC.Value = 10
local MCC = Instance.new("IntValue",leaderstats)
MCC.Name = "MegaClicksChance"
MCC.Value = 1
local ODMG = Instance.new("IntValue",leaderstats)
ODMG.Name = "OreDamage"
ODMG.Value = 1
local SP = Instance.new("IntValue",leaderstats)
SP.Name = "SuperPower"
SP.Value = 1
local MP = Instance.new("IntValue",leaderstats)
MP.Name = "MegaPower"
MP.Value = 1
local Gems = Instance.new("IntValue",leaderstats)
Gems.Name = "Gems"
local OD = Instance.new("IntValue",leaderstats)
OD.Name = "OreDamage"
OD.Value = 1
if Clicks.Value >= (9 * (10 ^ 17)) then
Clicks.Value = 0
Power.Value = 1
end
end)
Everything works, but I also made that if I get 900 quadrillion clicks, my power and clicks will reset. But I don't want that. I want atleast to know how to create a stat with amount of zeros in my clicks. If it will work, I will make that in GUI Counter will be shown like this: 10^x (x = amount of zeros)
Also, if you want to try my simulator, here's the link:
Click Simulator Beta 0.31

(Also roblox related)Countdown freezes at a random number

so there are 2 scripts: script and localscript.
The script determines how many seconds there will be and then it fires it to all player clients & the localscript changes the text to seconds. But when i tested the game the countdow freezes either at a number or a random number anyway here's the script again:
script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("IntermissonEvent")
local secondsRemaining = 15
for t = secondsRemaining, 0, -1 do
remoteEvent:FireAllClients(t)
wait(1)
end
localscript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("IntermissonEvent")
local function onTimerUpdate(seconds)
script.Parent.Text =(seconds)
wait(15)
script.Parent.Parent.CountdownText.Visible = false
script.Parent.Parent.IntermissionText.Visible = false
script.Parent.Parent.TextLabel.Text ="Vote for a Map!"
script.Parent.Parent.MapVotingFrame.Visible = true
end
remoteEvent.OnClientEvent:Connect(onTimerUpdate)
Your LocalScript is running all of this logic every single time the server fires the event. Instead of waiting, check the value with an if-then.
local function onTimerUpdate(seconds)
script.Parent.Text = tostring(seconds)
if seconds == 0 then
script.Parent.Parent.CountdownText.Visible = false
script.Parent.Parent.IntermissionText.Visible = false
script.Parent.Parent.TextLabel.Text = "Vote for a Map!"
script.Parent.Parent.MapVotingFrame.Visible = true
end
end

Manually Restart a Countdown Timer on a Form in Access Database

I have the following code to log off Access users automatically.
Most work will be completed in 5 minutes or less, but I would like to add a manual reset button below the counter that will restart the timer if needed.
I want to force the end user to manually start the timer over if needed.
Option Compare Database
Dim TimeCount As Long
Private Sub Form_Open(Cancel As Integer)
Me.TimerInterval = 1000
End Sub
Private Sub Form_Timer()
TimeCount = TimeCount + 1
Me.txtCounter.Value = 1200 - TimeCount
If TimeCount = 1201 Then
DoCmd.Quit acQuitSaveAll
End If
End Sub
How can I accomplish this task?
I have code to quit Access if the user is inactive. I know this isn't what you're looking for but it may help you out...if not, good luck!
Create a form called DetectIdleTime. Have it open when the database is loaded with the Window Mode set to Hidden.
On the OnTimer event in the DetectIdletime properties...
Sub Form_Timer()
Const IDLEMINUTES = 5
Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime
Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes
On Error Resume Next
ActiveFormName = Screen.ActiveForm.Name
If Err Then
ActiveFormName = "No Active Form"
Err = 0
End If
ActiveControlName = Screen.ActiveControl.Name
If Err Then
ActiveControlName = "No Active Control"
Err = 0
End If
If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IDLEMINUTES Then
ExpiredTime = 0
IdleTimeDetected ExpiredMinutes
End If
End Sub
Set the Timer Interval event on the DetectIdleTime form to 1000
Now Access will close if the user doesn't move the mouse...

Running Swift code in while loop but times out

I have following code that is supposed to do two things:
1) Fire blasters when temp is under 100 and blasters are not overheated.
2) Wait out until the temp is cooled down to zero.
I am not too sure why the codes below time out. I am a real beginner with Swift (I have an intermediate background in R.)
var shields = 5
var blastersOverheating = false
var blasterFireCount = 0
var temp = 0
while shields > 0 {
temp = temp + 1
blasterFireCount = blasterFireCount + 1
if temp == 100{
blastersOverheating = true
}
if blastersOverheating{
print("Sleeping to cool down to 0")
sleep(10)
temp = 0
blasterFireCount = 0
blastersOverheating = false
continue
}
print(temp)
}
If you run this code on a free online platform (like iswift.org/playground), your program will time out because it would run forever otherwise.
To counter this problem limit your loop so it only does, for example, 1000 cycles.
View the example online: http://swift.sandbox.bluemix.net/#/repl/59123b184ee0cd258050b2cd
var coolingDown = false
var blasterFireCount = 0
var temp = 0
for _ in 0..<1000 {
if coolingDown {
temp -= 1
print("cooling down \(temp)")
if temp == 0 { coolingDown = false }
} else {
temp += 1
blasterFireCount += 1
print("fire \(blasterFireCount)")
if temp == 100 { coolingDown = true }
}
}