Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont my Time subtraction handler work?

I have 2 scripts the first one is a local script inside of a ScreenGUI and the other is a ServerScript that's inside the ServerScript service all the local script does is handle my GUI and sometimes fire events. The ServerScript handlers the entire Time system(It isn't really like a countdown more like a value that determines the length of time in the wait() function.) This is the TimeHandler

SubtractTimeEvent.OnServerEvent:Connect(function(player).
	local PlayerGui = player:WaitForChild("PlayerGui") --everything after this doesn't work.
	if player.leaderstats.Bux.Value >= player.leaderstats.OtherStats.CaseSpeedCost.Value then
		player.leaderstats.OtherStats.CaseSpeed.Value -=.5
		player.leaderstats.Bux.Value -=player.leaderstats.OtherStats.CaseSpeedCost.Value
		player.leaderstats.OtherStats.CaseSpeedCost.Value +=2500
		print("Cost Updated.") --everything before this doesn't work.
	end
end)

This is the part of the local script that fires the event to activate the TimeHandler(CaseSpeed is a value that got collected by a local function,)

UpgradeTimeButton1.MouseButton1Click:Connect(function()
	if CaseSpeed.Value <= 2.5 then
		CaseSpeed.Value = 2.5
		UpgradeTimeButton1.Text = "MAXED"
	elseif CaseSpeed.Value >= 2.5 then
		SubtractTimeEvent:FireServer()
	end
	ClickSound:Play()
end)

1 answer

You shouldn't depend on a syntax feature that isn't supported with Lua's 5.1 Roblox has really been testing the features but -=, += & etc. can be really faulty.

2 comments

0

so should I do something like "player.leaderstats.OtherStats.CaseSpeed.Value = player.leaderstats.OtherStats.CaseSpeed.Value = .5"?

0

CaseSpeed.Value = CaseSpeed.Value - 0.5

This discussion is preserved as it was. New answers, comments, and votes are closed.