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

Part is not a valid member of Backpack?

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 comment

1

You're not parenting bulletyo to anything, hence bulletyo is effectively parented to nil.

1 answer

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

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