I'm very confused, can someone please help me figure out where to put the spawn function to spawn the spear? I'm making a game which involves crafting and really need all the help I can get.(Did I put it in the right place?)
script.Parent.Touched:connect(function(Part) if Part.Name=="Stick" and script.Parent.Name=="PointedStone" then workspace.Stick:remove() workspace.PointedStone:remove() end end) script.Parent:remove() function spawn()local Spear=Instance.new("Part", game.Workspace) --Adjust shape/color/size of product item here.1 Spear.CFrame=CFrame.new(Part.Position)--My change end end)
You really need to solidify more of your basics before going and making a crafting system.
The function will never run, because it's never called (read the wiki link for more info on functions). However, it would never even get created, because you destroy the script right before it!
Lua is read left to right, top to bottom. This means that if you want something to happen in a certain order, just put it in that order! In other words, if you want A
to be executed before B
, all you need to do is put B
below or to the right of A
in the script editor.
function func1() --Do stuff end function func2() --Do stuff end func1() func2()
func1
is now executed first because we called it first.
print("Hi") print("Hola")
"Hi"
prints before "Hola"
The same thing applies to your code.