FireServer is not a valid member of script

Hey Devs,

as I progress in my project ran into a road block which I figured was me trying to contact server with a local script.

bringing me to remote functions.

My issue is Error Code Screen Shot 2020-08-03 at 3.05.51 PM

no idea what this means and its no where to be found on forums…

the remote function is two parts,

  1. inside of a StarterGui:
local petName = player.EquippedPet.Value
		local petVal = Instance.new("StringValue")
		 petVal.Name = pet.Name
		petVal.Parent = player.PetInventory
		
	   local Event = game.ReplicatedStorage.PetRemote
       Event:FireServer(petName)
  1. Inside of Replicated Storage
local Event = Instance.new(game.ReplicatedStorage.PetRemote)
Event.Name = "PetRemote"
Event.OnServerEvent:Connect(function(Player,Value)
	  print("Value recived from client, Player:",Player.Name,"Value:",Value)
	
end)

now I renamed the script in Storage to be called PetRemote, that did nothing so need help please.

Use invoke server and onserverinvoke

1 Like

Also use Instance.new(“RemoteFunction”)
Event.Parent = game.replicatedstorage

2 Likes

A couple of things:

First of all, it appears (from the snippit of code you supplied) that you aren’t waiting for the RemoteEvent to be added to ReplicatedStorage before trying to use :FireServer, and it also seems like you are trying to use RemoteFunctions through RemoteEvent functions/properties.
For RemoteFunctions, you need to use things like this:

RemoteFunction:InvokeServer()

RemoteFunction.OnServerInvoke = function()

end

You also are trying to create a new instance of “game.ReplicatedStorage.PetRemote” but that won’t work, you need to use something like:

remote = Instance.new("RemoteFunction")
remote.Name = "PetRemote"
remote.Parent = game.ReplicatedStorage

I’ll also say you should NOT have the script in storage named to “PetRemote”, instead change it to something generic like “Script” so that it doesn’t interfere with other scripts trying to identify the remote.

1 Like

thank you!
both RemotionFunction and Remote are underlined red… am I missing something else?Screen Shot 2020-08-03 at 3.22.08 PM

use repeat wait(1) until game.replicatedstorage.remotefunction

1 Like

Or use game.replicatedstorage:WaitForChild(“RemoteFunction”)

1 Like

You need to use the name of the remote, i.e:

game.ReplicatedStorage.PetRemote
1 Like

getting an Infinite Yield when waiting on RemoteFunction

game.ReplicatedStorage:WaitForChild("PetRemote")

1 Like

I realized maybe it was cause I didn’t add the remote event into the RepStorage and that fixed that error

how would I handle

seems like the same issue with the FireServer() :frowning:
… this probably asking to much at this point but you guys have been super helpful!

The script in ReplicatedStorage, which I assume is called “PetRemote” (which would explain the error you got), should be located in ServerScriptService. You could also just insert a RemoteEvent into ReplicatedStorage manually which would also work.

Another reason why it would not work is that in your code, you wrote:

local Event = Instance.new(game.ReplicatedStorage.PetRemote)

which should have been:

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage

Also, would appreciate it if you could mark my post as solution if it worked :slight_smile:

3 Likes

moved it and sadly
" PetRemote is not a valid member of ServerScriptService"

but
Screen Shot 2020-08-03 at 3.52.15 PM
its clearly in there?!

could it be the script inside?

also getting the error at the top line of here

Localscripts don’t have access to anything inside ServerScriptService, that’s why it says its not a valid member of ServerScriptService. Also, you are treating scripts as if they are RemoteFunctions, that’s why you were getting that error before.

1 Like

I added it back into Replicated Storage
and added

local repStorage = game:GetService("ReplicatedStorage")

tried it in both the scripts local and one in rep storage and still error of

RemoteStorage is not a valid member of DataModel

I’m so tiny brain

Move the script back into ServerScriptService, then insert a RemoteFunction into ReplicatedStorage, and name it “PetRemote”, then on your script, replace this:

local RemoteFunction = game.ServerScriptService.PetRemote 

to:

local RemoteFunction = game.ReplicatedStorage.PetRemote
1 Like

wow worked perfectly! thanks!
only thing I think is the Invoke Servers are not firing do those work inside ServerScriptService?
cause im getting InvokeServer is not a valid member of RemoteEvent

I’m guessing you inserted a RemoteEvent instead of a RemoteFunction.

1 Like

are you sure you dont have a script with the same name? itll try and run the fireserver function on the script if you do.

1 Like

Don’t I double checked filter workspace I did have a RemoteFunction in RepStorage with same name but I changed and still same error