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

Simple error? Or... qq

function joined(plr)
local a = Instance.new("Hint", game.Workspace)
a.Text = plr.Name.. "has joined! | Age: " ..plr.AccountAge.. " | " ..plr.MembershipType
wait(10)
a:remove()
end
game.Players.PlayerAdded:connect(joined)

2 comments

1

You haven't said what the error in the output is, or what line the script breaks on.

0

"Workspace.Script:3: attempt to concatenate field 'MembershipeType' (a userdata value)"

1 answer

The problem is that MembershipType is an Enum. An Enum is a userdata value and cannot be concatenated.

There are two ways to do this. The easier way is to simply convert the enum to a string and chop off the Enum.MembershipType. part of it. This way it will return None, BuildersClub, TurboBuildersClub, or OutrageousBuildersClub.

function joined(plr)
	local a = Instance.new("Hint", game.Workspace)
	local membership = string.sub(tostring(game.Players.Player.MembershipType), 21)

	a.Text = plr.Name.. "has joined! | Age: " ..plr.AccountAge.. " | " .. membership
	wait(10)
	a:remove()
end

game.Players.PlayerAdded:connect(joined)

The other way to do this is to check which enum is being used and change the message accordingly. This allows you to use abreviations or what ever you'd like.

function joined(plr)
	local a = Instance.new("Hint", game.Workspace)
	local membership

	if plr.MembershipType == Enum.MembershipType.None then
		membership= "NBC"
	elseif plr.MembershipType == Enum.MembershipType.BuildersClub then
		membership= "BC"
	elseif plr.MembershipType == Enum.MembershipType.TurboBuildersClub then
		membership= "TBC"
	elseif plr.MembershipType == Enum.MembershipType.OutrageousBuildersClub then
		membership= "OBC"
	end

	a.Text = plr.Name.. "has joined! | Age: " ..plr.AccountAge.. " | " .. membership
	wait(10)
	a:remove()
end

game.Players.PlayerAdded:connect(joined)

2 comments

0

Thanks sooo much

0

No problem :)

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