script: script.Parent.Touched:Connect(function(hit) game.Players.LocalPlayer.PlayerGui.ShopGui.Frame.Visible = true end)
error: Workspace.Sell.Script:2: attempt to index nil with 'PlayerGui'
script: script.Parent.Touched:Connect(function(hit) game.Players.LocalPlayer.PlayerGui.ShopGui.Frame.Visible = true end)
error: Workspace.Sell.Script:2: attempt to index nil with 'PlayerGui'
This is a script on the part, so there is no such thing as LocalPlayer. Only in LocalScripts.
Try this instead:
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.ShopGui.Frame.Visible = true
end)
lmao
i got error:PlayerGui is not a valid member of Model
How about now?
Thanks!!!
how childish for sownvoting my answer for no reason, i only downvoted it because it was previously wrong
wasn't me
You copied my answer, raid6n. I made a very simple mistake, you downvoted me without telling me why and duplicated it, instead of making a simple comment correcting the ancestry of PlayerGui. You're the one being childish.
lmao
how about we both remove the downvote and go on with our day
sure
ok
You cannot use LocalPlayer in a server script, but you can use getplayerfromcharacter(hit.parent).
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.ShopGui.Frame.Visible = true
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
wow i can't believe i didn't know that back then