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

StarterGear is not valid member of Player error???

I have a shop. I typed the local script that you can purchased the item. It appears in backpack but why is not working with the starter gear i just want to save the purchased gear when the character died so that is not being repeated the process.This is my local script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tools = ReplicatedStorage:WaitForChild("Tools")
local SwordItem = Tools:WaitForChild("SwordToy")
local Buy = script.Parent
local Price = Buy.Parent.Price.Value
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")

script.Parent.MouseButton1Click:connect(function()
 if stats.Gold.Value >= Price then
  stats.Gold.Value = stats.Gold.Value - Price
  local cloned = SwordItem:Clone()
  local cloned2 = SwordItem:Clone()
  cloned.Parent = player:WaitForChild("Backpack")
  cloned.Parent = player.StarterGear -- this is line is error
  Buy.Text = "Successfully Owned"
 end
end)

Can you help me???

1 comment

0

startergear is a member of game, not player. A version of startergear is Backpack in the player.

1 answer

✓ Accepted answer

StarterGear is literally not a member of Player, it is game.StarterGear, even so I don't think you can edit it when the game is being played in a server, only in studio. So is meant to be

cloned.Parent = player.Backpack

you could add a datastore value telling the game that the player has this item and spawn the item/items when they load back into the game after death.

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