Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Simple PlayerHasPass code - why doesn't it work?

Asked by 9 years ago
function Click()
    local id = 227017712

    game.Players.PlayerAdded:connect(function(player)
        if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print'has pass'
        script.Parent.Parent.Parent.Parent.Character.Torso.CFrame = CFrame.new(-463.884, -15.558, 140.897)
    else
        script.LocalPlayer.StarterGui.NoPass.NoPass.Visible = true
        print'has no pass'
        wait(5)
        script.LocalPlayer.StarterGui.NoPass.NoPass.Visible = false
        end
    end)
end

script.Parent.MouseButton1Down:connect(Click)

no output,

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

--EDIT[2]--

Remove the PlayerAdded event - This is making it so whenever any player joins then their position gets set to the specified location.

This should be a regular script, define plr.

local id = 227017712
local plr --Define!

function Click()
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
        plr.Character.Torso.CFrame = CFrame.new(-463.884, -15.558, 140.897)
    else
        plr.PlayerGui.NoPass.NoPass.Visible = true
        wait(5)
        plr.PlayerGui.NoPass.NoPass.Visible = false
    end
end

script.Parent.MouseButton1Down:connect(Click)
0
This script moves the player to the position without even clicking the GUI button, that is not what I want it to do, I want the player to chose whenever he wants to teleport to the position during the game. excellentAnarchy 50 — 9y
0
Edited Goulstem 8144 — 9y
1
PlayerHasPass can't be used from a LocalScript. BlueTaslem 18071 — 9y
0
Edited[2] Goulstem 8144 — 9y
Ad

Answer this question