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

My badge required door isn't responding my script. How do I fix this?

Asked by 4 years ago

So I'm trying to create this RP game, and basically I tried to create a door with the badge required morph behind it. The problem is that whenever I touch the door nothing happens instead of teleporting me beyond the door, making me touch the morph for a brief second and then teleporting me out of the room. Also, the output won't speak. Here's my script:

local badge = game:GetService("BadgeService")

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if badge:UserHasBadgeAsync(plr.UserId, 2124584743) then
            hit.Parent.Torso.CFrame = CFrame.new(21.431, -0.028, 64.993)
            wait(0.5)
            hit.Parent.Torso.CFrame = CFrame.new(4.27, 0.44, 53.917)
        end
    end
end)
0
Are you sure you don't want to use .Position instead of .CFrame mixgingengerina10 223 — 4y
0
Using each of them made no difference. After playing around with a bit of print() I figured out where the problem occurs. I don't exactly know why it's happening, but I know that its not doing anything because of line 7. Prxticles 13 — 4y
0
What is the error? SteamG00B 1633 — 4y
0
Well its not doing anything. Even after making a new badge for the game. Prxticles 13 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I think the problem that is occuring is that the badge is not exactly from the game the script is in. For the RP game I've created, theres the main menu first, and then you select your desired map. I keep my maps seperate, and since I had the badge on the menu game, the script on the map game didn't work. I did waste a couple robux because of this, but I completely understand the meaning behind it. If this script actually worked, it would allow players to get badges from other popular games without actually achieving it.

0
You can't even use the teleport service if you keep your maps separate. SteamG00B 1633 — 4y
0
Huh. The teleport service worked for me. Prxticles 13 — 4y
Ad
Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
4 years ago

Hello, Prxticles.

Another way you could do this so it could be smoother is by using a LocalScript and putting it inside of StarterPlayerScripts.

local Client = game.Players.LocalPlayer
local BadgeService = game:GetService("BadgeService")
local Door = -- Path to your door

if BadgeService:UserHasBadgeAsync(Client.userId, 2124584743) then
    Door.CanCollide = false
end

Answer this question