Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-3

What should i use to replace function 'tostring'?

Asked by 8 years ago

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)
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. M39a9am3R 3210 — 8y
0
i put 6 in and it works fine kentasoro 0 — 8y
0
You need to put a value in the actual function, otherwise it will not work. M39a9am3R 3210 — 8y
0
LOL i have to say i have never seen this before.. good job? evaera 8028 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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.

Ad

Answer this question