Badge Door Failing

Hello Scripters,
My friend is a very inexperienced scripter and wanted to create a badge door, or a door that would only let you passed if you own a badge. Because he’s in experienced he’s using two year old tutorials and nothing is working, he also can’t use the DevForum so I’m saying this on his behalf. The code is shown below.

local Player = game.Players.LocalPlayer
local BadgeService = game:GetService("BadgeService")

local BadgeTable = {
    {
        Door = game.Workspace.Door,
        BadgeId = 00000000000
    }
}

for LoopNum, Badge in pairs (BadgeTable) do
    if BadgeService:UserHasBadgeAsync(Player.UserId,Badge.BadgeId) then
        Badge.Door.CanCollide = false
    end
end

The door, without the badge isn’t able to be gone through and even with the badge you can’t go through it. How can this be changed?

1 Like

I’m not sure why he is using a table here, it’s quite weird to use a table for a badge, now let me get this right, your goal is to make the door open/Collision off when someone with a badge hits the door. Another question, is the full code because I don’t really see any touch functions or anything.

1 Like

This is the exact code that he was using, and collision. Just need some way to get through the door. So I’d assume it’s the full thing.

1 Like

This works. All you have to do is go to StarterPlayer → StarterPlayerScripts click the ‘+’ and add a localscript and paste this code into the localscript (Works for me) make sure to actually put a badgeId you own to test it.

1 Like

I’m sending it to my friend now, thanks for this. I feel really stupid for not seeing this.

1 Like

(Explination for my answer to help your friend understand)

Basiaclly a localscript is Client sided which means Player.
Script is server sides which means game.

If you need to access player data then try to use localscripts (In starterGui if UI, PlayerScripts if for Player Data & CharacterScripts if for the Character)

Make sure that you dont try to access thing like LocalPlayer as the game doesnt know which player that means. There is ONE client per person (ie. it knows who its user is) but one server for (exaple) 27 clients which means there are 27 localplayers.

Your welcome :smiley:

1 Like


He’s very appreciative of you :wink:

1 Like

lol just happy to help :smiley:

CHALIMITCHALIMITCHALIMITCHALIMITCHALIMIT

1 Like

(Please keep in mind that bc thiss is local script that the Door will only be Non-Collide for that player only) Which is what you wanted im pretty sure.

Yes, that’s exactly what was need

1 Like

This isn’t really secure. The player could just exploit and get through the door without some server-side protection.

That is true, since the script is after a client.

It’s not for a game he’s making, he wanted it for a small challenge for friends. So the current script is secure enough. And you could also just clip through the door.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.