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?
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