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

Function Return Help? attempt to concatenate string with function

Asked by 4 years ago

The error is on line 29, trying to set the name so in another script it can tell if the part touched anything. I am purposely doing this on the client side. If there is anyway I can do this inside this script keeping it on the client, let me know. Here is my local script, inside a tool:

local gun = script.Parent
local ammo = game.ReplicatedStorage.NormalGunAmmo
local ActiveBullets = game.Workspace.ActiveBullets

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local debounce = false
local count = 0

local function number()
    for i,v in pairs(ActiveBullets:GetChildren())do
        count = count+1
    end
    return count
end

gun.Activated:Connect(function()
    if debounce == false then
        debounce = true
        local bullet = ammo:Clone()
        bullet.CFrame = gun.Handle.CFrame

        local BodyVelocity = Instance.new("BodyVelocity",bullet)
        BodyVelocity.P = Vector3.new(10000,10000,10000)
        BodyVelocity.Velocity = mouse.Hit.LookVector * 100

        bullet.Parent = ActiveBullets
        bullet.Name = "Bullet"..number
        wait(.75)
        debounce = false
    end
end)

Error is in the title, and again, it occurs on line 29 trying to set the name, thanks!

0
Plus, you should declare another variable, since the script can get confused. CrypxticDoge 135 — 4y
0
plus? JailBreaker_13 350 — 4y
0
Replace line 29 with bullet.Name = "Bullet"..number() rabbi99 714 — 4y
0
thanks! JailBreaker_13 350 — 4y

Answer this question