function click()
local stick = script.Parent
local Player = game.Players.LocalPlayer
repeat wait(.01) until Player:FindFirstChild("PlayerGui")
wait(.1)
stick.Transparency = 1
stick.CanCollide = false
stick.ClickDetector.MaxActivationDistance = 0
local num = Player.PlayerGui.ScreenGui.Frame.rockSec.num.Text
Player.PlayerGui.ScreenGui.Frame.rockSec.num.Text = num + 1
end
script.Parent.ClickDetector.MouseClick:connect(click)
I have a rock and I when I click the rock I want it to add 1 to the 'PlayerGui.ScreenGui.Frame.rockSec.num.Text'. When I run this in studio it works fine. When I run it in an actual game I get the error like:
"Workspace.Rock.rockClicked:6: attempt to index local 'Player' (a nil value)"
I'm confused about how to fix this because it works fine in Roblox Studio.

2 comments
ugh is this in a localscript...?
It's not, will that fix everything? I thought local scripts wouldn't let me change transparency and such.