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

Part is not a valid member of Backpack?

Asked by
Dwayder 29
6 years ago

Hello, I'm trying to make a simple gun script for a tool in StarterPack.

local tool = script.Parent
local dollarbill = game.ServerStorage.DollarBill
local dspawnpos = script.Parent.Shadow.Position
local bodypos = Instance.new("BodyPosition")
local bulletyo = script.Parent:FindFirstChild("bulletyo")


script.Parent.Activated:connect(function(fire)
    if (bulletyo == nil) then
    bulletyo = dollarbill:Clone()
    bulletyo.Position = Vector3.new(dspawnpos)
    bulletyo.Velocity = Vector3.new(50,50,50)
    bodypos.Parent = bulletyo
    bodypos.MaxForce = Vector3.new(0,98,0)
    print("Not a single error.")
    end
end)

It prints "Not a single error." just once after I click, but the script is not actually doing what its supposed to. However, in the output I get that "Shadow", which is a part somewhere in the tool is not a valid member of Backpack. Am I doing this wrong?

1
You're not parenting bulletyo to anything, hence bulletyo is effectively parented to nil. DevNetx 250 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

First off, ServerStorage can only be viewed by the server, not the client(like in a LocalScript) and you are calling it WRONG. You should call it like:

local serverStorage = game:GetService("ServerStorage")

In a LocalScript you should use ReplicatedStorage and call it like ServerStorage.

Also, you should parent "bulletyo" to something:

bulletyo.Parent = aRandomThing
Ad

Answer this question