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

RemoteEvent error help?

I keep getting OnServerInvoke is not a valid member of RemoteEevent

Invoke server script

while true do
	wait(60)
	mainmod:Appear()
	mainmod:Spin(5)
	game.Workspace.DataStore.StoreData:InvokeClient(script.Parent.Parent.Parent.Name, script.Parent.Parent.MoneyDisplay.Money.TextLabel.Text)
	mainmod:Dissapear()
end

Reciver

script.StoreData.OnServerInvoke(function(player, amount)
	MoneyStore:SetAsync("Money_"..player, amount)
end)

4 comments

0

Is the local script in workspace?!

0

The local script is in playergui

0

You have the player name, not the player itself. Also is script.Parent.Parent.Parent etc the character or the player?

0

I got the name of the player

2 answers

✓ Accepted answer

Use OnServerInvoke as an event

script.StoreData.OnServerEvent:connect(function(player, amount)
	MoneyStore:SetAsync("Money_"..player, amount)
end)

edit - changed to OnServerEvent

5 comments

0

same error

0

Mistook that for a RemoteFunction. You want OnServerEvent instead of OnServerInvoke

0

now there is no error but nothing is happening :<

0

It should be ("Money_"..player.Name, amount)

0

you should be using userid if you want their stats to save if they change their name, bruh

Do what @SFOH said to do, use OnServerEvent instead of OnServerInvoke, also, you forgot the "connect" part or your code. But there is another error in your first script, If you're invoking a local script you need the first argument to be the PLAYER. Not the Player's NAME.


#Final Product ##Reciver

script.StoreData.OnServerEvent:connect(function(amount)
    MoneyStore:SetAsync("Money_"..game:GetService("Players").LocalPlayer, amount)
end)

##ServerScript

while wait(60) do
    mainmod:Appear()
    mainmod:Spin(5)
    game.Workspace.DataStore.StoreData:InvokeClient(game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent.Parent), script.Parent.Parent.MoneyDisplay.Money.TextLabel.Text)
    mainmod:Dissapear()
end

Hope it helps!

3 comments

0

View source, I have the player in there also I have tested it and doesn't work :<

0

@NotSoNorm on line 2 of the first script, he still needs to add LocalPlayer.Name

0

@HungryJaffer, It still works either way.

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