Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

4 comments

0

Are you sure you don't want to use .Position instead of .CFrame

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.

0

What is the error?

0

Well its not doing anything. Even after making a new badge for the game.

2 answers

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.

2 comments

0

You can't even use the teleport service if you keep your maps separate.

0

Huh. The teleport service worked for me.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.