Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I set an objects Parent to something that I have set as a variable?

Asked by 6 years ago

I'm trying to copy/paste a Folder into a Player's inventory using this script. Everything is running fine until I get to making the copied folders parent AllStats on line 22. The problem is because "meme isn't a valid member of Players" even though I've set it up as a variable to be whomever touches the blocks username. Help?

local block = script.Parent

local pressed = false

local function finish(otherPart)

if not pressed then

    pressed = true

    local points = block:FindFirstChild("Midori Ruins")

    local meme = otherPart.Parent.Name

print(points)
print(meme)

local stats = block["Midori Ruins"]

local copy = stats:Clone()

copy.Parent = game.Players.meme.leaderstats.AllStats

wait(1)

    pressed = false

    end

end

block.Touched:Connect(finish)
0
You want to use square brackets or FindFirstChild(). e.g. game.Players:FindFirstChild("meme").leader..... ScrewDeath 153 — 6y
0
Oops, I meant game.Players:FindFirstChild(meme).leader.... no quotes ScrewDeath 153 — 6y

Answer this question