Script won't work. It doesn't recognize the item

My script isn’t working. I feel like it’s something obvious, but I don’t yet understand everything about lua coding. It says:
12:28:35.490 Fame is not a valid member of Folder “Workspace.MrProYouTube.WoodCam.Values” - Server - RemoteHandler:5

– local ReplicatedStorage = game.ReplicatedStorage game.ReplicatedStorage.RemoteEvents.Fame.OnServerEvent:Connect(function(player, valueFolder) if player.Debounce.Value == false then player.leaderstats.Fame.Value = player.leaderstats.Fame.Value + valueFolder.Fame.Value*(player.leaderstats.Rebirths.Value + 1) player.Debounce.Value = true wait(valueFolder.Cooldown.Value) player.Debounce.Value = false end end)

– local ReplicatedStorage = game.ReplicatedStorage 
game.ReplicatedStorage.RemoteEvents.Fame.OnServerEvent:Connect(function(player, valueFolder)
 if player.Debounce.Value == false then 
player.leaderstats.Fame.Value = player.leaderstats.Fame.Value + valueFolder.Fame.Value*(player.leaderstats.Rebirths.Value + 1) player.Debounce.Value = true 
wait(valueFolder.Cooldown.Value) player.Debounce.Value = false end end)

Error says it all, “Fame” couldn’t be found. Either you made a spelling mistake or it doesn’t exist or it needs time to load.

1 Like

Possible solutions :

  • Re-check your spelling
  • Wait for the object to load :
    game.ReplicatedStorage.RemoteEvents:WaitForChild(“Fame”, math.huge) .OnServerEvent …

Just try to add a wait at the start.

I found a typo and fixed it, but now it says;
" 13:11:05.401 fame is not a valid member of Folder “Players.MrProYouTube.leaderstats” - Server - RemoteHandler:5"
&
“13:11:06.485 fame is not a valid member of Folder “Players.MrProYouTube.leaderstats” - Server - RemoteHandler:5”

“fame” can’t be found, again I think that the object needs time to load. Use WaitForChild()

local ReplicatedStorage = game.ReplicatedStorage
ReplicatedStorage.RemoteEvents.fame.OnServerEvent:WaitForChild(function(player, valueFolder)
if player.Debounce.Value == false then
player.leaderstats.fame.Value = player.leaderstats.fame.Value + valueFolder.fame.Value*(player.leaderstats.Rebirths.Value + 1)
player.Debounce.Value = true
wait(valueFolder.Cooldown.Value)
player.Debounce.Value = false
end
end)

Now it says:
" 13:34:56.542 WaitForChild is not a valid member of RBXScriptSignal - Server - RemoteHandler:2"

Why do you have it wrapping your function, up there where it says

is the problem. WaitForChild is used to Wait for an object to load and the code wont be yielded unlike repeat wait() until obj name. Basically the code queues for a property of an object to change once it’s loaded. WaitForChild is not used for functions, sorry if im slow or cant explain good, i am on a mobile device currently and I write sloppily.

1 Like

I suggest you read this for better explanation by the ROBLOX team, it also includes examples of how it is suppose to be used.