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

Attempt to perform arithmetic on upvalue 'time' (a table value)?

Hi, I used some code in Sceleratis's Kohl Admin Epix Edition script to make a script that would insert a GUI into all players' PlayerGui, show a message, and close the message, using the same code that does the ":sm " command of the Kohl Admin script.

When I extracted the code and tested it, the GUI inserts into the players' PlayerGui, and shows the message, but the message refuses to close; displaying this error:

08:23:24.223 - Workspace.Kohl Epix MSG:85: attempt to perform arithmetic on upvalue 'time' (a table value)

This is the line the error is pertaining (Line 12)

if scroll then 
	if not time then 
		for i = 1, #str do msg.Text = msg.Text .. str:sub(i,i) 
			wait(1/19) 
		end 
		wait(2.5) 
	else 
		for i = 1, #str do 
			msg.Text = msg.Text .. str:sub(i,i) 
			wait(1/19) 
		end 
		wait(time-(#str/19)) 
	end
elseif not time then 
	msg.Text = str 
	wait((#str/19)+2.5) 
else 
	msg.Text = str 
	wait(time) 
end

This is the full script, for further reference:

local set={
	['PrimaryColor'] = Color3.new(0,0,0); --Primary GUI Color (Default black) (Remember, each 1 translates to a 255, keep that in mind when changing colors, use things like 124/255 to get the color you want)
	
	['SecondaryColor'] = Color3.new(1,1,1); --Secondary GUI Color (Default white)
	
	['Font'] = 'SourceSansBold'; --Font
	
	['TextColor'] = Color3.new(1,1,1); --Text Color (Default white)
	
	['TextStrokeTransparency'] = 0; --Text Stroke Transparency (0-1)
	
	['TextStrokeColor'] = Color3.new(0,0,0); --Color of the text stroke around letters (Default black)
	
	['Transparency'] = 0.5; --Main GUI Transparency (0-1)
	
	['Animations'] = true; --Determines if to animate stuff or not
	
	['MessageAnimations'] = true; --Same as above but specifically for messages
}

set.GuiName=tostring(math.random(10000000,99999999))
_G['Hint']=function(msg,ptable) set.Hint(msg,ptable) end
_G['Message']=function(title,msg,ptable) set.Message(title,msg,true,ptable) end

local localplayer=game:service('Players').LocalPlayer

set.Message=function(ttl, str, scroll, time)
local v=localplayer
if v and v:findFirstChild("PlayerGui") then
coroutine.wrap(function()
local scr = Instance.new("ScreenGui") scr.Name = set.GuiName.."MessageGUI"
local bg = Instance.new("Frame", scr) 
bg.Name = "bg" 
bg.BackgroundColor3 = set['PrimaryColor'] 
bg.BorderSizePixel = 0 
bg.BackgroundTransparency = 0
bg.Size = UDim2.new(1,0,1,0) 
bg.Position = UDim2.new(0,0,-1,0)--UDim2.new(-1,0,1,0)
bg.ZIndex = 8
local title = Instance.new("TextLabel", bg) 
title.Name = "title" 
title.BackgroundTransparency = 1 
title.BorderSizePixel = 0 
title.Size = UDim2.new(1,0,0,10) 
title.Position = UDim2.new(0,0,0,20)
title.ZIndex = 9 
title.Font = set.Font 
title.FontSize = "Size36" 
title.Text = ttl 
title.TextYAlignment = "Top" 
title.TextColor3 = set['TextColor']
title.TextStrokeColor3 = set['TextStrokeColor'] 
title.TextStrokeTransparency=set.TextStrokeTransparency
local msg = title:clone() 
msg.Parent = bg
msg.Name = "msg" 
msg.Position = UDim2.new(.0625,0,0) 
msg.Size = UDim2.new(.875,0,1,0) 
msg.Font = set.Font 
msg.Text = "" 
msg.FontSize = "Size24" 
msg.TextYAlignment = "Center" 
msg.TextColor3=set['TextColor']
msg.TextStrokeColor3=set['TextStrokeColor']
msg.TextWrapped = true
bg.ClipsDescendants=true
bg.BackgroundTransparency=set.Transparency
scr.Parent = v.PlayerGui
if set.Animations and set.MessageAnimations then
	bg:TweenPosition(UDim2.new(0,0,0,0),'Out','Quad',1,false)
else
	bg.Position=UDim2.new(0,0,0,0)
end
if scroll then 
	if not time then 
		for i = 1, #str do msg.Text = msg.Text .. str:sub(i,i) 
			wait(1/19) 
		end 
		wait(2.5) 
	else 
		for i = 1, #str do 
			msg.Text = msg.Text .. str:sub(i,i) 
			wait(1/19) 
		end 
		wait(time-(#str/19)) 
	end
elseif not time then 
	msg.Text = str 
	wait((#str/19)+2.5) 
else 
	msg.Text = str 
	wait(time) 
end
local moved=false
local function move()
if not scr then return end
if set.Animations and set.MessageAnimations then
	bg:TweenPosition(UDim2.new(0,0,1,0),'Out','Quad',1,true,function() moved=true scr:Destroy() end)
else
	bg.Position=UDim2.new(1,0,1,0)
end
wait(1.1)
if not moved then move() end
end
pcall(move)
wait(0.3)
pcall(move)
pcall(function() wait(1) scr:Destroy() end)
end)()
end
end

set.RemoveMessage=function()
local v=localplayer
for q,ms in pairs(v.PlayerGui:children()) do
if ms.Name == set.GuiName.."MessageGUI" then
ms:Destroy()
elseif ms.Name == set.GuiName.."HintGUI" then
ms:Destroy()
end
end
end

set.Message("SYSTEM MESSAGE", "Hello.", true, game:service('Players'):children())

1 answer

✓ Accepted answer

I am not a very good scripting, but since no one has answered, let alone comment I will give it a go! The problem might be that you are trying to subtract the variable "Time" by (str divided by 19). As I have learned, you cannot arithmicize (is that the right tense?) in a function or string! This probably isn't right, but it might spark someone right to answer!

{EDIT] Did you ever define what time is? It seems to be trying to subtract the word time by (str divided by 19)!!!

3 comments

1

So I should make it (Time/str) instead, for example?

0

No, try defining what time is, unless you already did! If you already did then try doing what number value inside the script, and then have it go to that for time

0

I fixed it by replacing the "time by str divided by 19" with an integer. Thanks for pointing that out.

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