This is due to the fact you’re attempting to access the rock inside ReplicatedStorage
, not the Workspace
. I would create a listener for when new rocks are created using the ChildAdded
event.
Sorry for the later response but I did what you said and it seems to go into the right direction and the Event is recived but there is an issue
with finding the rock in ReplicatedStorage a second time
here is my error:
Rock2 is not a valid member of Folder “ReplicatedStorage.Rocks”
I checked in the server and it showed that there was im not sure how this happened
Can I see the logic that creates the rocks?
-- Function to spawn a rock at a random location
local function spawnRock()
--local RandomRock = RS.Rocks:GetChildren() -- Get all rocks in the Rocks folder
--local ChooseRock = RandomRock[math.random(1, #RandomRock)] -- Select a random rock
local ChooseRock = RS.Rocks.Rock2
print(ChooseRock)
print("spawning") --Test Prints
local clone = ChooseRock:Clone() -- Clones Our Random Rock
local randomPos = possibleLocations[math.random(1, #possibleLocations)] -- Places Rock in one of the Locations
randomPos.IsTaken.Value = true
clone.Position = randomPos.Position
clone.Parent = WS.Rocks
end
-- Initial Rock Spawn
spawnRock()
-- Rock Respawn on Event Trigger
Event.OnServerEvent:Connect(function()
Rock:Destroy()
print("recived") --test print
task.wait(RespawnTime)
spawnRock()
end)
The Rock initially spawns but when it has to respawn it shows me the error:
Rock2 is not a valid member of Folder “ReplicatedStorage.Rocks”
What is Rock
defined as here?
oh I had the Replicated Storage rock called
Thank you for your help It works after I defined the rock as it should be
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.