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

Event is not a valid member of ReplicatedStorage?

So I have a RemoteEvent Inside ReplicatedStorage, And it's saying it's not a valid member. Here is the source : Class (LocalScript) Location (game.ReplicatedFirst)

local rstorage = game:GetService("ReplicatedStorage")
local event = rstorage.Event
local date = os.date("%I:%M:%S")
local player = game.Players.LocalPlayer
while true do wait(1)
event:FireServer(player,date)
end

this is it

If anybody could answer will mark it as a answer. (Depend's on if its' correct.)

3 comments

0

sorry if im not clear

0

it seems you are not doing the right locations

0

i am and it gives errors

1 answer

✓ Accepted answer

ReplicatedFirst will, as it says replicate first. This means that whatever is inside it will be replicated into the client as soon as the game loads up.

For this reason, some of the items in the other services might have not even been loaded in yet. Therefore, we can call a Method on ReplicatedStorage called WaitForChild(). This will ensure we wait for the child to be loaded in.

Here is how you would apply it to your piece of code.

local rstorage = game:GetService("ReplicatedStorage")
local event = rstorage:WaitForChild("Event")
local date = os.date("%I:%M:%S")
local player = game.Players.LocalPlayer

while true do wait(1) -- consider changing this to "while wait(1) do"
	event:FireServer(player,date)
end

I hope this helps :)

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