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

What should i use to replace function 'tostring'?

there is 6 different enemies so id rather make it easier if possible name is 'Enemy1,Enemy2' ext 04:24:52.059 - Players.Player1.PlayerGui.Gui.Bars.Bars:8: attempt to concatenate global 'tostring' (a function value)

local hud = script.Parent.Parent
local core = hud.Core
local enemies = hud.FightArea.Enemies
local team = hud.FightArea.Team
local enemy = hud.Enemy
local ally = hud.Ally
	
	enemy["Enemy"..tostring()].Stats.HP.Changed:connect(function()
	if enemy["Enemy"..tostring()].Stats.HP.Value <0 then
		enemy["Enemy"..tostring()].Stats.HP.Value = 0
		hud.Dead.Enemy.Value = hud.Dead.Enemy.Value + 1
		if hud.Dead.Enemy.Value == 6 then
		core.Gold.Value = core.Gold.Value + core.GoldDrop.Value
		enemy["Enemy"..tostring()].Stats.HP.Value = enemy["Enemy"..tostring()].Stats.MaxHP.Value
		core.kills.Value = core.kills.Value + 1
		if core.Kills.Value >= 10 then
			hud.FightArea.nextstage.Visible = true
			end
	end
	end
	enemies["Enemy"..tostring()].HPBar.hptext.Text = enemy["Enemy"..tostring()].Stats.HP.Value.."/"..enemy["Enemy"..tostring()].Stats.MaxHP.Value
	hud.FightArea.Kills.Text = core.Kills.Value.."/".."10"
	enemies["Enemy"..tostring()].HPBar.Bar:TweenSize(UDim2.new(enemy["Enemy"..tostring()].Stats.HP.Value/enemy["Enemy"..tostring()].Stats.MaxHP.Value,0,1,0), "Out", "Quad", 0, false)
	end)

4 comments

0

You're using tostring improperly. You would have to place a variable or value inside the parenthesis to have the function return the string.

0

i put 6 in and it works fine

0

You need to put a value in the actual function, otherwise it will not work.

0

LOL i have to say i have never seen this before.. good job?

1 answer

#Nothing

Look at what you're doing. Your tostring is redundant, as it's simply taking nothing as an argument. Remove it and your script will stop erroring from it.

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