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

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

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

10 comments

0

br0000 use a code block pl0x

0

sorry about that now I fixed it,

0

So do you need help anymore?

0

If you don't put the [Solved] next to your text in title

0

oh I just mean't I fixed the question. still need help

0

I am still getting that last error even though I chanced it it Plr=game.Players.LocalPlayer

0

Okay lemme see

0

You didn't post the whole script.

0

It says error at 36th line and you pasted only 14 lines, btw is tihis in Workspace or StarterGui?

0

oh this was workspace

2 answers

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)

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

1 comment

0

OOOOH TY ALL. It worked now!

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