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

Why is it erroring checking for gamepass in localscript?

Asked by 5 years ago

Error: "Cannot find player.userid" What would be the correct format for localscript? I've tried without userid

    repeat wait(.1) until game.Players.LocalPlayer.Character ~= nil
repeat wait(.1) until game.Players.LocalPlayer.Character.Humanoid ~= nil
player = game.Players.LocalPlayer
mouse = player:GetMouse()

local char = player.Character
local roll = Instance.new("Animation")
roll.AnimationId = "rbxassetid://3027027786"
local animloader = char.Humanoid:LoadAnimation(roll)
function KeyD(key)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userid, 6014768) then
    key = key:lower()
    local hotkey = script.Hotkey

    if key == hotkey.Value then
        local animloader = char.Humanoid:LoadAnimation(roll)
        animloader:Play()
    end
    end
end

mouse.KeyDown:connect(KeyD)


function Move(key)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userid, 6014768) then
key = key:lower()
if key == "w" or key == "a" or key == "s" or key == "d" then
animloader:Stop()
    end
end
end

mouse.KeyDown:connect(Move)

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

roblox updated userId to UserId, change that

the keyDown part needs to change to this

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()

mouse.KeyDown:Connect(function(key)
    local Key = key.lower("key in here")
    if key == ("same key in here") then
        function here
    end
end)
0
if it works then pls accept answer Gameplayer365247v2 1055 — 5y
0
That still doesn't work. UnderWorldOnline 59 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

userid needs to be properly formatted to UserId or it will error. Replace both instances of it in your script the error will stop. The updated script should look like this:

``` repeat wait(.1) until game.Players.LocalPlayer.Character ~= nil repeat wait(.1) until game.Players.LocalPlayer.Character.Humanoid ~= nil player = game.Players.LocalPlayer mouse = player:GetMouse()

local char = player.Character local roll = Instance.new("Animation") roll.AnimationId = "rbxassetid://3027027786" local animloader = char.Humanoid:LoadAnimation(roll) function KeyD(key) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 6014768) then key = key:lower() local hotkey = script.Hotkey

if key == hotkey.Value then
    local animloader = char.Humanoid:LoadAnimation(roll)
    animloader:Play()
end
end

end

mouse.KeyDown:connect(KeyD)

function Move(key) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 6014768) then key = key:lower() if key == "w" or key == "a" or key == "s" or key == "d" then animloader:Stop() end end end

mouse.KeyDown:connect(Move) ```

On a side note, KeyDown is deprecated due to its inability to detect multiple key presses at a time. A post on the developer wiki can be found here explaining how to integrate new and better key input methods into your game.

Answer this question