There are multiple errors in this script we will run through.
Firstly, I want you to take a look at this if statement explanation.
##Error 1: Impossible If Statement.
The if statement you have is impossible. Let's take a look at it and put it in English.
if Part.Name=="Stick" and Part.Name=="PointedStone" then
Translated to a real life situation this would be:
If my name is Drake, and my name is Ben, then...
It's impossible. You only have one name, and can only index one name. I know what you are trying to accomplish, so let me try to assist a bit
if script.Parent.Name=="Stick" and Part.Name=="PointedStone" then
We can also switch this and say:
if Part.Name=="Stick" and script.Parent.Name=="PointedStone" then
Or, you could only put this script inside Sticks and PointedStone's, then only have 1 condition such as;
if Part.Name=="Stick" then
or;
if Part.Name=="PointedStone" then
##Error 2: Spear Spawn
In your current script, you don't have the spawn inside the if, which will cause the spear to spawn no matter what, whenever the script is ran (on server startup).
4 comments
Thanks, I'm gonna test it again later tonight, hope it works :)
Spawn? Can you please elaborate, I'm confused.
See how you create a new part in workspace OUTSIDE of the event? That's what he's talking about. Your "Spear" will spawn (come into existence; get created) immediately when the server starts, no matter what.
Like this? 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