I have a script in ServerScriptService that should wait 5 seconds and pick a number between 1 and 3. It should then choose which crate to get from the ReplicatedStorage from the random number selected. These three crates are 'weaponCrate', 'armorCrate' and 'beveragesCrate'. It should then fire an event to the client, so that the client can enable GUI stating that a crate is about to spawn. The crate selected should then be cloned, parented to the Workspace, and given a new name 'spawnedCrate'. The crate (which is a model by the way) should then move to the position of a part in the Workspace called 'crateSpawnLocationA', and then a sound should play, parented to the script. FilteringEnabled is ON.
When I run the script however, I get an error saying 'crateSpawnLocationA is not a valid member of Workspace'. I've tried to use FindFirstChild(), and I get an error saying 'Cannot index a nil value', and I've also tried to use WaitForChild(), but I get an error saying 'Infinite yield possible at game:GetService("Workspace").crateSpawnLocationA'. I've tried turning FilteringEnabled off, but that hasn't effected anything.
Can someone please help me?
My code is below:
wait(5) crateNumber = math.random(1,3) if crateNumber == 1 then crate = game:GetService("ReplicatedStorage").weaponCrate elseif crateNumber == 2 then crate = game:GetService("ReplicatedStorage").armorCrate elseif crateNumber == 3 then crate = game:GetService("ReplicatedStorage").beveragesCrate end game:GetService("ReplicatedStorage").crateSpawned:FireAllClients(crateNumber) crate = crate:Clone() crate.Parent = game:GetService("Workspace") crate.Name = "spawnedCrate" crate:MoveTo(game:GetService("Workspace").crateSpawnLocationA.Position) script.Sound:Play()