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
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