Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can my script not find some folders under ServerStorage?

Asked by 4 years ago

I am trying to code an ability system. When the player first joins, I create a folder inside a folder inside of server storage. This folder that I just create is named after the player.

ServerStorage -> SelectedAbilities -> Player one

In a script stored under ServerScriptService, I try to call upon it when the buttons "Q" and "E" are pressed. Here is my current code for when this happens.

local selectedAbilities = game.ServerStorage:FindFirstChild("SelectedAbilities")
local plrObject = selectedAbilities:FindFirstChild(player)

abNumb = plrObject.Ability2.Value
ab = abModule.AbilityReturn(abNumb) 
print("Ability2 = "..ab)

The issue is that plrObject, the variable, is returning nil causing the script to break.

I confirmed the variable player to be equal to the player name. I have also confirmed selectedAbilities to be the correct object. Because this script only activates after a button is pressed, the likely hood that the objects aren't loaded in is about zero. I will continue to look into this and keep this post updated but any help will be appreciated

Thanks, Bees

0
Is the script local or server? CaptainAlien132 225 — 4y
0
The script is a normal script stored under the ServerScriptService beeswithstingerss 41 — 4y
0
Have you tried :WaitForChild()? CaptainAlien132 225 — 4y
0
Could you show the module BlackOrange3343 2676 — 4y
View all comments (2 more)
0
If 'player' is a Player instance, print(player) will print the player's name, but that doesn't make player a string. Overall, you're not showing us enough code to debug this. How you're getting key input from client to server is of course important. EmilyBendsSpace 1025 — 4y
0
Thank you Emily for bring this to my attention. You are correct in saying this. If you paste this comment into an Answer, I'll accept it for you. beeswithstingerss 41 — 4y

Answer this question