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

Attempt to field 'UserId' error?

Asked by
vkax 85
5 years ago

So this is my script, also if you could help me improve my datastore usage and stuff, that would be great and show me some things to limit with, that would really help, but other than that, I get this error that says "Attempt to field 'UserId'", my username is "trycode" and I was just testing the banning thing on myself.

This is the script:

game.Players.PlayerAdded:connect(function(player)
    player:WaitForDataReady()
    local datastore = game:GetService("DataStoreService"):GetDataStore("LocalHost")
    local banned = datastore:GetAsync(player.UserId"-Banned") or nil

    if player.Name == "trycode" then
        datastore:SetAsync(player.UserId"-Banned","test")
    end 

    if banned~=nil then
        local GiveBanGui = script.Banned:Clone()
        GiveBanGui.Parent = player.PlayerGui
        GiveBanGui.LocalScript.Disabled = false
        player:Kick("You have been banned!")
    end
end)

This is inside the local script in the ban GUI

script.Parent.Changed:connect(function()
_G.GiveBanReason = function(player)
    return game:GetService("DataStoreService"):GetDataStore("Localhost"):GetAsync(player.UserId"-Banned")
end

script.Parent.Frame.TextLabel = "You have been banned\nReason: ".._G.GiveBanReason(game.Players.LocalPlayer)
end

So yeah, if you can help me, then thanks :)

P.S. I'm making a game called Mouse Trap, read more about it on this studio: https://www.roblox.com/My/Groups.aspx?gid=4085786

1
Put '..' between player.UserId and "-Banned" KingLoneCat 2642 — 5y

Answer this question