Wow I can’t believe I missed that. Thanks @1Urge
He is right, Turn ‘character:Clone()’ into a variable then try just remember to replace character with the variable name
If this fixes it mark his reply as the solution please
Thanks!
I put this:
local charclone = character:Clone()
player.Character = charclone
charclone.Parent = workspace
but the character doesn’t teleport to one of the spawns
The spawning worked! Thanks! Now is the teleport
This is because you are referencing the old HRP. Make your HRP variable after you parent the new character to the player and then try teleporting.
I did this:
buy.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local leaderstats = player:WaitForChild("leaderstats")
if leaderstats:FindFirstChild("Yen").Value < 100 or db or not HRP then return end
db = true
local charclone = character:Clone()
player.Character = charclone
charclone.Parent = workspace
local HRP = charclone and charclone:FindFirstChild("HumanoidRootPart")
local random = math.random(#SpawnsTable)
HRP.Position = SpawnsTable[random].Position + Vector3.new(0, 5, 0)
task.wait(1)
db = false
end)
but nothing teleported or character got morphed
In your lesderstats line, you are checking to see if the hit part doesn’t have a HRP variable which hasn’t been created yet, so that would check out.
Either check for the HRP by typing out the path to it, or put the leader stats check after you make your HRP variable. I’m surprised there was no error in the output since HRP wasn’t created before you referenced it there.
If you ever find any errors in the output, please include them in your replies.
Thanks! It worked! The teleporting and morphing finally worked.
Thanks for your help, and the other people!
Happy to help. When you can, mark one of my posts as the solution so others who have this problem can find a solution easier. Thanks!