Is it possible to access the Player on workspace in order to set trasparency for an Accessory? Example:
for _, v in pairs(workspace:WaitForChild(game.Players.LocalPlayer.Name)) do if v:IsA("Accessory") then v.Transparency = 0.5 end end
game.Players.LocalPlayer.Name not work: Player is not a valid member of DataModel
This will not work because LocalPlayer is only accessible by local scripts. I assume you want this to happen when someone joins? If so I have forged a script below
Make sure you put this in a server/regular script. If there are any errors tell me.
game.Player.PlayerAdded:Connect(function(plr) local char = plr.Character for _, v in pairs(char:GetChildren()) do if v:IsA("Acessory") then v.Handle.Transparency = 0.5 end end
You can't access LocalPlayer in Workspace. That's your problem.
local players = game:GetService("Players") for _, player in pairs(Players:GetPlayers()) do ---- then you could check if the player has certain accessory or whatever you're trying to do end end
Hope this works.
Problem solved:
local plr = game.Players.LocalPlayer.Name for _, v in pairs(workspace[plr]:GetChildren()) do if v:IsA("Accessory") then v.Handle.Transparency = 0.5 end end
To be able to access LocalPlayers. You will need to have a local script. If you don't you cant access a localplayer from a server script.
LocalPlayer is only accessible from LocalScripts in ReplicatedFirst, PlayerGui, or the player's backpack. See this page for more info: https://developer.roblox.com/en-us/api-reference/property/Players/LocalPlayer
-- I assume you have put this in a script type other than localscript, -- You can only Access LocalPlayer from a LocalScript.