function onMouseClick(player)
print('player who clicked is ' .. player.Name)
player.PlayerGui.Obtained.Enabled = true
player.PlayerScripts.Items.Keys.Value = true
wait(5)
player.PlayerGui.Obtained.Enabled = false
end
script.Parent.ClickDetector.MouseClick:connect(onMouseClick)
This script works fine in studio testing but when I start a server it doesn't work? Do I need to put it in a local script?
Ok, I figured it out, thanks for anyone who helped. I just needed a Remote Function to create a KeysObtained Remote Event and a local script within the Gui.

3 comments
You can't access PlayerGui/PlayerScripts from the server.
How would I go about doing this then? I have the game set up where theres a folder of items for each player saved in PlayerScripts, how would I access those?
Use a remoteevent