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

[SOLVED] Help! My screenGui code isn't working correctly and I don't know how to fix it?

Asked by 6 years ago
Edited 6 years ago

I need help trying to figure out what exactly is wrong with this code. I am pretty new to roblox scripting and this is my first time trying scripting helpers. Does anyone know how I can fix this exactly?

local function VictoryMessage(Plr)
    for _,Plr in pairs(game.Players:GetPlayers()) do
    local screenGui = Instance.new("ScreenGui")
    screenGui.Parent = Plr.PlayerGui
    local textlabel = Instance.new("TextLabel")
    textlabel.Parent = screenGui
    textlabel.Position = UDim2.new(0.25,0,0.25,0)
    textlabel.Size = UDim2.new(0.3,0,0.3,0)
    textlabel.BackgroundColor3 = Color3.new(55,55,55)
    textlabel.Text = Plr .."Has Won"
    wait(5)
    textlabel:Destroy()
    end
end

everytime I use it, I get


":32:59.189 - Workspace.racing light.Script:36: attempt to concatenate local 'Plr' (a userdata value)"

also sorry about this but idk how to display the code in a more readable manner

0
br0000 use a code block pl0x INOOBE_YT 387 — 6y
0
sorry about that now I fixed it, dragonspade21 15 — 6y
0
So do you need help anymore? AswormeDorijan111 531 — 6y
0
If you don't put the [Solved] next to your text in title AswormeDorijan111 531 — 6y
View all comments (6 more)
0
oh I just mean't I fixed the question. still need help dragonspade21 15 — 6y
0
I am still getting that last error even though I chanced it it Plr=game.Players.LocalPlayer dragonspade21 15 — 6y
0
Okay lemme see AswormeDorijan111 531 — 6y
0
You didn't post the whole script. AswormeDorijan111 531 — 6y
0
It says error at 36th line and you pasted only 14 lines, btw is tihis in Workspace or StarterGui? AswormeDorijan111 531 — 6y
0
oh this was workspace dragonspade21 15 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 5 years ago

This is the second post to it

local function VictoryMessage(Plr)
local   Plr = game.Players.LocalPlayer
    local screenGui = Instance.new("ScreenGui")
    screenGui.Parent = Plr.PlayerGui
    local textlabel = Instance.new("TextLabel")
    textlabel.Parent = screenGui
    textlabel.Position = UDim2.new(0.25,0,0.25,0)
    textlabel.Size = UDim2.new(0.3,0,0.3,0)
    textlabel.BackgroundColor3 = Color3.new(55,55,55)
    textlabel.Text = Plr .."Has Won"
    wait(5)
    textlabel:Destroy()

end

and this is the error again

17:02:46.288 - Workspace.racing light.Script:36: attempt to concatenate local 'Plr' (a userdata value)
Ad
Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago

Hello, dragonspade21!

Test this:

local function VictoryMessage(Plr)
    for _,Plr in pairs(game.Players:GetPlayers()) do
    local screenGui = Instance.new("ScreenGui")
    screenGui.Parent = Plr.PlayerGui
    local textlabel = Instance.new("TextLabel")
    textlabel.Parent = screenGui
    textlabel.Position = UDim2.new(0.25,0,0.25,0)
    textlabel.Size = UDim2.new(0.3,0,0.3,0)
    textlabel.BackgroundColor3 = Color3.new(55,55,55)
    textlabel.Text = Plr.name .."Has Won" --Error is here, Plr is a UserdataValue, not text(SOLVED)
    wait(5)
    textlabel:Destroy()
    end
end

Good Luck with your games

0
OOOOH TY ALL. It worked now! dragonspade21 15 — 6y

Answer this question