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

How do I fix "RemoteEvent is not a valid member of ReplicatedStorage" error message?

I have a script that teleports players at the start of a game and has messages that show up on a TextLabel. For some reason it is not working, so I looked at the warnings and error messages. The error message says "RemoteEvent is not a valid member of ReplicatedStorage", and there are warnings that say "Unknown global 'player'". There are blue underlines under where it says player in the remote.FireClient spot. I appreciate any help. Thanks!

EDIT: I have fixed the "RemoteEvent is not a valid member of ReplicatedStorage" error and the "Unknown global 'player'" warnings, but now it says "FireClient: player argument must be a Player object". I don't know why it says this as I believe am using a Player object, as shown below in my code. Thanks for helping, and sorry for the beginner questions.

Script code:

local oldMessage = ""
local minPlayers = 1
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local messagePlayerEvent = Instance.new("RemoteEvent")
messagePlayerEvent.Parent = game.ReplicatedStorage
messagePlayerEvent.Name = "MessagePlayerEvent"
 
function teleportPlayers()
	local TeleportTarget = ""
	local target = CFrame.new(workspace.StartP1.Position)
	for i, player in ipairs(game.Players:GetChildren()) do
		TeleportTarget = (string.format("StartP%s", i))
		target = CFrame.new(workspace[TeleportTarget].Position)
		player.Character.HumanoidRootPart.CFrame = target
		player.Playing.Value = 1
	end
end
 
function message(message)
	if oldMessage ~= message then
		oldMessage = message
		print(message)
	end
end
 
function playersCurrentlyPlaying()
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.Playing.Value == 1 then return true end
	end
	return false
end

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			player.Playing.Value = 0
		end)
	end)
 
	local playing = Instance.new("IntValue", player)
	playing.Value = 0
	playing.Name = "Playing"
end)
while(true) do
wait(10)
    if #game.Players:getPlayers() >= minPlayers then
        if playersCurrentlyPlaying() then
            local text = "Waiting for an available arena..."
            messagePlayerEvent:FireClient(player, text)
        else
            local text = "There are enough players for a new game!  Teleporting..."
            messagePlayerEvent:FireClient(player, text)
        wait(4)
            teleportPlayers()
        end
    else
        local text = "Waiting for more players..."
        messagePlayerEvent:FireClient(player, text)
    end
end

LocalScript code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local messagePlayerEvent = ReplicatedStorage:WaitForChild("MessagePlayerEvent")

messagePlayerEvent.OnClientEvent:Connect(function(text)
    script.Parent.Text = text
end)

6 comments

0

Is there a remote event named RemoteEvent in replicated storage?

0

I don't know so I am reading about remote events.

0

Ok so you defined the player as localPlayer so this has to be a local script, but you're using FireClient, which is meant to be sent from the server to a client. You need to use FireServer if this is a local script.

0

On a server script you cant use LocalPlayer. Thats why the player argument isnt working.

0

What would I use instead?

0

Never mind I am asking a new question

1 answer

✓ Accepted answer

The error you said you got means the item wasn't there. It might have been a typo. If it wasn't there wasn't a instance named "RemoteEvent" in ReplicatedStorage. If this if this isn't help, I would like a screenshot of the ReplicatedStorage.

4 comments

0

This should be a comment, not an answer.

0

There is a new error now; I have put it in the question. Could you try to help me with that? Thanks.

0

This question was already answered, please open a new question.

0

Sorry, I didn't realize you have to make a new thing for a new question. I will open one now.

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