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

Error with textboxes filtering enabled?

Asked by 7 years ago

23:58:28.507 - Players.rubene45.PlayerGui.RadioGlobal.Frame.ID.Script:14: attempt to concatenate local 'ID' (a userdata value).

local PonerMusica = game.Workspace.PonerMusicaGlobal
local PararMusica = game.Workspace.PararMusicaGlobal
local Texto = game.Workspace.PonerMusicaGlobal2
Debug = 0

local function PonerMusicaGlobal()
    if Debug == 0 then
        Debug = 1
        Audio = Instance.new("Sound")
        Audio.Name = "Audio"
        Audio.Parent = game.Workspace
        Audio.Looped = true
        local ID = script.Parent
        Audio.SoundId = "rbxassetid://"..ID
        Audio:Play()
    end
end

local function PararMusicaGlobal(p)
    if Debug == 1 then
        Debug = 0
         Audio.Looped = false
        Audio:Stop()
    end
end


PararMusica.OnServerEvent:Connect(PararMusicaGlobal)
Texto.OnServerEvent:Connect(PonerMusicaGlobal)
0
It is a server script! rubene45 2 — 7y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

By looking at your script i'm guessing that the script's name, that this code is in, is the ID of a sound you want to use. If so the reason it's erroring is because you are trying to concatenate the script with the string, to make this we need to give it the script's name which is a string.

local ID = script.Parent.Name
Audio.SoundId = "rbxassetid://"..ID

Result:

local PonerMusica = game.Workspace.PonerMusicaGlobal
local PararMusica = game.Workspace.PararMusicaGlobal
local Texto = game.Workspace.PonerMusicaGlobal2
Debug = 0

local function PonerMusicaGlobal()
    if Debug == 0 then
        Debug = 1
        Audio = Instance.new("Sound")
        Audio.Name = "Audio"
        Audio.Parent = game.Workspace
        Audio.Looped = true
        local ID = script.Parent.Name
        Audio.SoundId = "rbxassetid://"..ID
        Audio:Play()
    end
end

local function PararMusicaGlobal(p)
    if Debug == 1 then
        Debug = 0
         Audio.Looped = false
        Audio:Stop()
    end
end


PararMusica.OnServerEvent:Connect(PararMusicaGlobal)
Texto.OnServerEvent:Connect(PonerMusicaGlobal)
Ad

Answer this question