Hey im trying to make a script of a gui button
sudo `on button clicked
if player has game pass id 000000001
get player(player)
playerstage = player.leaderstats.stage
if workspace.stages.tostring(playerstage) then
teleport player to workspace.stages.tostring(playerstage)
else
show message "Whoa Hold up That stage hasnt loaded it please wait." `
else offer to buy game pass 00000001
heres what i have...
Gamepassid = 000000000
function Click(mouse)
player = game.Players.LocalPlayer.Name
if game:GetService("GamePassService"):PlayerHasPass(player, Gamepassid)then
character = player.Character
stage = tostring(player.Leaderstats.Steps.Value)
stagepart = game.Workspace.Steps:FindFirstChild(stage)
stagepos = stagepart.CFrame
if game.Workspace.Steps:FindFirstChild(stage)== nil then
msg = Instance.new("Hint")
msg.Text = "Step still Loading Please try again in a few seconds"
else
character.HumonoidRootPart.CFrame.Value = stagepos + CFrame.new(0,3,0)
end
else
game:GetService("MarketplaceService"):PromptPurchase(player,Gamepassid)
end
end
script.Parent.MouseButton1Down:connect(Click)
the out out shows Unable to cast value to Object on line 7 ...
the whole script is probably wrong please help :(

1 comment
you defined player as the player's name but the first argument to PlayerHasPass needs an instance of the player