Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

A directory to GUI containing a variable is not recognizing the variable?

script.Parent.Touched:Connect(function(HIT)
    local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
        local meep = game.Players.player.PlayerGui.ScreenGui.Shop
        meep:TweenPosition(UDim2.new(0.5,0,0.6,0),'In','Bounce',0.5)
        wait(0.5)
end)

script.Parent.TouchEnded:Connect(function(HIT)
    local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
local meep = game.Players.player.PlayerGui.ScreenGui.Shop
        meep:TweenPosition(UDim2.new(1.5,0,0.6,0),'Out','Bounce',0.5)
wait(0.5)
end)

So, the title is pretty self explanatory.

in line 3 and 10, there is

local meep = game.Players.player.PlayerGui.ScreenGui.Shop

The script is not recognizing "player" as a variable and thinks it is a real child of player. How do i fix this?

1 answer

✓ Accepted answer

You could use the player's name, as in

local meep = game.Players[player.Name].PlayerGui.ScreenGui.Shop

but that's bad, don't do that.

player is the Player object. So you can just use it directly, like this:

local meep = player.PlayerGui.ScreenGui.Shop

1 comment

0

Oh wow! XD i'm so stupid. Thanks for your answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.