Problem with script | Doesn't work

What is the problem here? When I had one of these scripts, it worked flawlessly, now when I added the second one for another item, it does not work. Both are named the same - “Spawn” and both are in ServerScriptService

>
> local ARS = game.Workspace.ItemSpawnAreas.ArrowRokaSpawns
> local player = game.Players.LocalPlayer
> local serverstorage = game:GetService("ServerStorage")
> local isa = workspace.ItemSpawnAreas
> local arrow = serverstorage["StandArrow"]
> local arrowspawns = isa.ArrowRokaSpawns
> local CFrame1 = CFrame.new(Vector3.new(isa.ArrowRokaSpawns:GetChildren("Part")))
> function spawnitem(item, spawner)
> local location = spawner:GetChildren()[math.random(1, #spawner:GetChildren())]
> local clone = item:Clone()
> clone.Parent = workspace
> clone.Handle.Position = location.CFrame
> game.Debris:AddItem(clone, 600)
> end
> while true do
> wait(0.5)
> spawnitem(arrow, arrowspawns)
> wait(0.5)
> print("Arrow Spawned")
> end
> SECOND SCRIPT:
> 
> local ARS = game.Workspace.ItemSpawnAreas.ArrowRokaSpawns
> 
> local player = game.Players.LocalPlayer
> 
> local serverstorage = game:GetService("ServerStorage")
> 
> local isa = workspace.ItemSpawnAreas
> local roka = serverstorage["Rokakaka Fruit"]
> local rokaspawns = isa.ArrowRokaSpawns
> local CFrame1 = CFrame.new(Vector3.new(isa.ArrowRokaSpawns:GetChildren("Part")))
> function spawnitem(item, spawner)
> local location = spawner:GetChildren()[math.random(1, #spawner:GetChildren())]
> local clone = item:Clone()
> clone.Parent = workspace
> clone.Handle.Position = location.CFrame
> game.Debris:AddItem(clone, 600)
> end
> while true do
> wait(0.5)
> spawnitem(roka, rokaspawns)
> wait(0.5)
> print("Roka Spawned")
> end
1 Like

I’m not a great scripter, but I’m actually assuming that it could be because both are named “Spawn.” You should change them to “Spawn1” and “Spawn2.” It might not help, but I’d try it.

well thanks, however it did not fix my issue

You can only use this line in a Local Script, not in ServerScriptService

then what do i do? what do i put

Well after looking through your scripts, you can just delete those localplayer lines because you don’t use the variables after creating them anyway. For the rest of the script, you really don’t need them both because they’re almost identical.
Your scripts merged into a single script if it helps:

local ARS = game.Workspace.ItemSpawnAreas.ArrowRokaSpawns
local serverstorage = game:GetService("ServerStorage")
local isa = workspace.ItemSpawnAreas
local arrow = serverstorage["StandArrow"]
local roka = serverstorage["Rokakaka Fruit"]
local arrowspawns = isa.ArrowRokaSpawns
local rokaspawns = isa.ArrowRokaSpawns
local CFrame1 = CFrame.new(Vector3.new(isa.ArrowRokaSpawns:GetChildren("Part")))
function spawnitem(item, spawner)
local location = spawner:GetChildren()[math.random(1, #spawner:GetChildren())]
local clone = item:Clone()
clone.Parent = workspace
clone.Handle.Position = location.CFrame
game.Debris:AddItem(clone, 600)
end
while true do
wait(0.5)
spawnitem(arrow, arrowspawns)
spawnitem(roka, rokaspawns)
wait(0.5)
print("Arrow Spawned")
print("Roka Spawned")
end
1 Like

woah man, so this is done now i just paste it? also i got an error “ServerScriptService.Spawn:15: invalid argument #3 (Vector3 expected, got CFrame)” how do i fix it

local CFrame1 = CFrame.new(Vector3.new(isa.ArrowRokaSpawns:GetChildren("Part")))

This will be the line causing the error. GetChildren creates a table of objects so can’t be used like this.
You will need to change it to something like this:

local CFrame1 = isa.ArrowRokaSpawns.Part.CFrame

Where Part is the name of the part who’s CFrame you want to reference.

ok thanks, ill try it a bit later if thats ok, i found some viruses(backdoors) in scripts i need to remove

sadly it doesnt work i have no idea why

Definitely change the name of the scripts to spawn1 and spawn2 like @Batmanissupercoolbro said.
Is there any spot on your script(s) where you refrence the script “spawn”? (Example: game.ServerStorage.Spawn)

1 Like

that is not a problem anymore, someone gave me a combined script but for some reason, it gives me an error "CFrame1 is not a valid member of Part “Workspace.ItemSpawnAreas.ArrowRokaSpawns.Part3” and it’s always the different part that says here’s my script I would really appreciate it if you would look at it
local ARS = game.Workspace.ItemSpawnAreas.ArrowRokaSpawns

local serverstorage = game:GetService("ServerStorage")

local isa = workspace.ItemSpawnAreas

local arrow = serverstorage["StandArrow"]

local roka = serverstorage["Rokakaka Fruit"]

local arrowspawns = isa.ArrowRokaSpawns

local rokaspawns = isa.ArrowRokaSpawns

local CFrame1 = isa.ArrowRokaSpawns.Part.CFrame

function spawnitem(item, spawner)

local location = spawner:GetChildren()[math.random(1, #spawner:GetChildren())]

local clone = item:Clone()

clone.Parent = workspace

clone.Handle.Position = location.CFrame1

game.Debris:AddItem(clone, 600)

end

while true do

wait(1)

spawnitem(arrow, arrowspawns)

spawnitem(roka, rokaspawns)

wait(1)

print("Arrow Spawned")

print("Roka Spawned")

end

--[[ Last synced 7/4/2021 09:08