Recently i’ve been having an issue with my teapot script for my remake of “dodge the teapots of doom”.
the issue is once i’m in game, when i touch the teapot in game, i do not die. i’m very new to scripting and the script used was open source so it could help me understand what i need to complete better. kinda like a guide.
i’ve tried reverting the game, and nothing works. i’ve tried changing variables, moving things to different locations, and all that kind of stuff. i haven’t added anything new to the game, so it doesn’t make any sense to me why the game would break.
here are the errors it’s showing me.
i’m very new to scripting so this could be an easy fix. dunno.
this error only occurs when i touch said teapot.
things to note:
teapots are stored under a folder in server storage
remover script below is listed under replicated storage
If you look at the console, he’s mentioning another “Teapots”, maybe check with another script in a different place or check if the path for “Teapots” is correct
Edit: Actually if the “Teapots” in ServerStorage is moved to Workspace by a script maybe try to use :WaitForChild() then
Maybe Teapots.Spawn is located inside a map and not workspace itself? If that’s the case try the script below:
local part = script.Parent
part.Touched:Connect(function(hit)
local char = hit.Parent
--script -> Teapot -> Pots -> Teapots but inside a specific map
--i assume you didn't change any of the path locations
local teapots = script.Parent.Parent.Parent
if char and char:FindFirstChild("Humanoid") then
char:SetPrimaryPartCFrame(teapots.Spawn.CFrame*Vector3.new(0, 5, 0))
end
end)
task.wait(10)
part:Destroy()
tried this. like i said in another reply, i failed to mention that there are multiple maps inside the ‘Maps’ folder. them being Map1, Map2, etc until Map5.
after trying this script i was greeted with this error, not fixing the damage bug.
adding to this comment, there are no other scripts involving teapots in the game. there are 2 others, being a MapChanger which just swaps maps to another after a period of time, and a MapReciever which just notifies a timedelay numbervalue in replicated storage so the map actually changes.
these scripts have had no problems, but i thought it was worth noting.
From this I assume that only one map will ever be in the workspace at once.
If this is true, it may be a good idea to give the clone that’s in the workspace a generic name like “Map” so that you can find the teapots easier. Then all you would need to do is hit.Parent:SetPrimaryPartCFrame(workspace.Map.Teapots.Spawn.CFrame + Vector3.new(0, 5, 0))
when you say the clone of the map, there never was a clone. the map is just moved into workspace. (i could also just be understanding this wrong because i’m very new to this)
with your suggestion, should i just replace that line of code with line 3 of the remover?
When I’m spawning maps, I like to clone the map instead of swapping it in because I then have a permanent reference of that map that is never leaving storage. When giving maps generic names like this, it may also save you from needing to store the original name somewhere when you want to name it back and place it into storage again (although needing the original name may come up later anyway).
Yes, simply replacing that line of code will work.
If you’re parenting these named clones directly to the workspace, all you should need to do is change their name to “Map” (in the MapChanger) and this line of code should be able to find them. If the in-game hierarchy is different than this, we may need to see a screenshot of the workspace’s children when a map is currently loaded.
here is a screenshot of the map changing script. i don’t really want to ruin it since it’s been toyed with one to many times, more the less kinda guide on what i should change here…
I notice that the map is still called Map5 in the output. I put the scripts we’ve been working with into an empty game and the map renamed fine with no errors, so I’m not perfectly sure what the issue is at this point.
Just in case, here are the two scripts I edited:
MapChanger:
local Replicated = game.ReplicatedStorage
local ServerStorage = game.ServerStorage
local MapsFolder = ServerStorage.Maps
local MapTimer = Replicated.MapTimer
function NewMap()
for i, v in pairs(MapsFolder:GetChildren()) do
if game.Workspace:FindFirstChild(v.Name) then
game.Workspace:FindFirstChild(v.Name):Destroy()
end
end
local Children = MapsFolder:GetChildren()
local Index = math.random(#Children)
local ChosenName = Children[Index]
local MapFound = MapsFolder:FindFirstChild(ChosenName.Name)
local Clone = MapFound:Clone()
Clone.Name = "Map"
Clone.Parent = game.Workspace
print("Changing Map To " .. ChosenName.Name)
end
game.ReplicatedStorage.MapTimer:GetPropertyChangedSignal("Value"):Connect(function()
if game.ReplicatedStorage.MapTimer.Value <= 0 then
NewMap()
game.ReplicatedStorage.MapTimer.Value = 100
end
end)
Remover:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:SetPrimaryPartCFrame(game.Workspace.Map.Teapots.Spawn.CFrame + Vector3.new(0, 5, 0))
end
end)
wait(10)
script.Parent:remove()