You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I would like to be able to make a script that spawns/respawns prey. -
What is the issue? Include screenshots / videos if possible!
The prey spawns once, thats it. Even if the right conditions are met. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tweaked it a bit, but because Idk what’s wrong with it, I didn’t do too much besides fixing errors that I thought would help.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Heres my script:
local Prey = game.ReplicatedStorage.Prey
local PreySpawn = script.Parent
game.Players.PlayerAdded:Connect(function(player)
local Char = player.Character or player.CharacterAdded:Wait()
local PlrRoot = Char.HumanoidRootPart
local SpawnRange = (PlrRoot.Position - PreySpawn.Position).magnitude
print(SpawnRange)
if SpawnRange >= 10 then
wait(5)
print(SpawnRange)
local NewPrey = game.ReplicatedStorage.Prey:Clone()
NewPrey.Parent = game.Workspace
print("prey has spawned")
NewPrey.HumanoidRootPart.Position = Vector3.new(408.78, 265.563, -153.644)
end
end)
As you can see, I put quite a bit of print statements. Everything prints on first try, but after that the ones in the If statement wont print, like it hasn’t fired, if that makes any sense.
No errors are popping up in the output. This script is quite amateur I would say so the problem I’m sure is the way I wrote it.
if you need more/different info, please ask and I will provide.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.