RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"ServerScriptService.Leaderstat:3: attempt to index nil with 'WaitForChild'"
This error message is indicating that the code is trying to access a property or method on a nil value. In this case, it seems that the code is trying to call the WaitForChild method on a nil value. To fix this error, you need to make sure that the object you are trying to access actually exists and is not nil. You can do this by checking if the object exists before calling any methods or properties on it. For example, instead of calling WaitForChild directly on the object, you can first check if the object exists using the FindFirstChild method. If the object is found, you can then call WaitForChild on it. Here's an example of how you can modify the code to avoid this error: local leaderstats = game:GetService("ServerScriptService"):WaitForChild("Leaderstats") local coins = leaderstats:FindFirstChild("Coins") if coins then coins.Value = coins.Value + 25 end In this example, we first check if the "Coins" object exists in the "Leaderstats" object. If it does, we can then safely access its Value property without causing any errors.