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

I'm sure this is right, but it tells me there's an error, what's wrong?

The error says the Message is not a part of Workspace

local Message = game.Workspace.Message


If game.Players.NumPlayers == 1 then
wait(0.1)
Instance.New ("Message", Workspace)
wait(1)
Message = "You are the only Player!"

2 answers

✓ Accepted answer

That's actually pretty far from right. The main problem is that you're trying to access Message in Workspace when it doesn't exist. You're probably looking to do something like this:

--This line creates a new message object for you to use. "Message" is the name of the object you want to make, and Workspace specifies for this object to be in the  workspace.
local Message = Instance.new("Message", Workspace)

-- This line starts an infinite loop, repeating the code in between this line and its corresponding "end" until the game is over.
while true do 

	-- This line checks if there is only one player in the server.
	if game.Players.NumPlayers == 1 then 
		-- If the condition above is true, it will set the message text here.
		Message.Text = "You are the only player!"
	-- "else" is what happens when the above condition is not true.
	else
		-- since it isn't true, clear the message.
		Message.Text = ""
	-- End the if
	end

	-- make sure this loop doesn't crash the server
	wait(1)

-- end the "while true do"
end

Remember that everything in Lua is case sensitive, in that "Instance.New" is different from "Instance.new", "If" is different from "if", and so on.

local Message = Instance.new("Message")
Message.Parent = Workspace
local Players = game.GetService('Players')
if Players.NumPlayers == 1 then
wait(0.1)
Message.Text = ("You are the only Player!")
wait(5)
Message.Text = ('')
return
end

1 comment

0

The mistake turned out that I forgot the .text lol

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