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

How to access player in regular script?

Asked by 7 years ago
local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local Commands = {}


function Commands.FadeShop()
local FadeFrame = Instance.new('Frame',PlayerGui)
FadeFrame.Size = UDim2.new(0,10,0,10)

for i = 1,0,-.1 do 
wait(.1)
FadeFrame.BackgroundTransparency = i
end

end









return Commands

Player is a Nil Value(Error)

I am sorry this question was deleted by accident D:

0
The question you need to answer is: **Which player??** BlueTaslem 18071 — 7y
0
the player playing the game Faker243 43 — 7y
0
There are many players playing the game... ROBLOX is multiplayer BlueTaslem 18071 — 7y

4 answers

Log in to vote
-1
Answered by
StoIid 364 Moderation Voter
7 years ago
Edited 7 years ago

Use GetCharacterFromPlayer().

More Info On GPFC

0
i cant accept the answer Faker243 43 — 7y
0
it wont let me Faker243 43 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

You can cycle through all the players in a game like below...

for i, v in pairs(game.Players:GetChildren()) do --i for index, v for reference to player
    if(v.Name == "PlayerNameHere") then
        --set-up gui or do whatever you want here
    end
end

--If you want to do it for all the players then just remove the if statement
for i, v in pairs(game.Players:GetChildren()) do --i for index, v for reference to player
    --set-up gui or do whatever you want here
end

I'm not sure if script.Parent.Parent.Parent will work, and personally I think that is more confusing. This is the ideal way to do, either do the same thing for all players, or search through the players for that particular player you want to modify things under.

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago
local Player = script.Parent.Parent.Parent --remove or add Parents depending where your script it

mine was in StarterGui.Child.Child.Script

so script.Parent.Parent.Parent the third .Parent made it go to StarterGui.

one more .Parent would be the Player


try this

function onPlayerEntered(Player)

local PlayerGui = Player:WaitForChild('PlayerGui')

local Commands = {}





function Commands.FadeShop()

local FadeFrame = Instance.new('Frame',PlayerGui)

FadeFrame.Size = UDim2.new(0,10,0,10)



for i = 1,0,-.1 do

wait(.1)

FadeFrame.BackgroundTransparency = i

end

end

return Commands
game.Players.ChildAdded:connect(onPlayerEntered) 

0
it's in the workspace Faker243 43 — 7y
0
you'd have to move the script then or use a localscript User#12356 0 — 7y
0
He is asking for a regular script, not a local script dragonkeeper467 453 — 7y
Log in to vote
-5
Answered by 7 years ago
Edited 7 years ago
--all you have to do is make it a local script and put
game.Players.LocalPlayer
0
really bro Faker243 43 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
View all comments (5 more)
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
XD The best answer of them all. KingLoneCat 2642 — 7y
0
Woah... Spammed ;-; How? KingLoneCat 2642 — 7y

Answer this question