How to make a key to open a door local?

Hello!

I want to make a tool, for example our key, to open a door. But, instead, it is local so it only happens for the local player.

I don’t know how to make a key that opens a door so I don’t have a script just incase anyone wonders.

Any help works. Thanks.

EDIT: Thanks to everyone who has commented! I will be testing and trying some of these out to see if they work! Thank you :slight_smile:

1 Like
1 Like

That’s for server sided not client sided.

1 Like

LocalScripts exist for an reason, only forgot to mention that

I was literally saying the video is irrelevant towards the OP… Have you even watched the video?

1 Like

Well, there are numerous ways to achieve this, however… why are you limiting yourself ONLY to the client? Are you sure this is the exact method you want? This can be easily exploited as handling this kind of stuff directly on the client could cause for some unwarranted exploiters to easily be able to manipulate data for your game and possibly even open the door without even finding the key! :open_mouth:.

Could you furthermore expand upon your idea and try to help me grasp what exactly it is you’re trying to achieve so we can find a better method for your problem?

1 Like

I wonder if people actually read what the OP wants. Hmm! Well this can improve latency.

1 Like

Ah, I see. A misconception, I was basing my post based on the first reply, my bad.

To achieve what he’s trying to do, couldn’t you technically just have a check (boolean) of whether or not the character actually has the value when trying to open the door, deny if no and open if yes?

You’d have to make some sort of no clip anti cheat since yeah no clip just ruins most games. Maybe you’d have to resort to client sided anti cheats.

You might think client sided anti cheats are useless. However, it does get rid of “some” exploiters. (If manipulated correctly)

Well, most exploiters. For the smarter, however, they can easily manipulate data with an array of methods.

Considering it’s only a “small” amount of exploiters that can do that, it wouldn’t be that impactful anyways.

Until they start releasing the script for other exploiters to use. But that’s fully hypothetical.

Yes and that’s probably why developers have to constantly update their anti cheats…(a very annoying process)

Unfortunately.

That’s how the wheel turns with security.

Patch → Anti-patch

Repeat!

Realistically you could just do door operations on the client side, but have checks on the server. For the most part this is pretty safe (and honestly much cleaner anyway). There’s a lot of documentation out there for door mechanics so I won’t add to what’s available.

(Keeping this simple here)

I’ve been looking at this one for a decent while, and I’ll be glad to explain the process behind it (In a different way :thinking:)

So what the OP wants, is for a Key to open a Door but it’ll be only visible to those who opened the specific door

Now obviously we need our 2 main objects here, the Locked Door & the Key to open the Door with:

There are tons of ways to really do this, but I’ll just stick with my “creative” & “fun” way on how to implement it :upside_down_face:

Now the first thing what we’d wanna do, since this’ll be to all individual clients, is put our Key inside StarterPack, cause we want to clone this for all Player Characters that join the game here

Next up, we’ll insert a LocalScript inside the Tool which will handle the Event that checks for unlocking the door:

local LockedDoor = workspace:WaitForChild("LockDoor")
local Key = script.Parent

local Connection

local function Touched(Hit)
	if Hit == LockedDoor then
		Connection:Disconnect()
		LockedDoor.Transparency = 0.75
		LockedDoor.CanCollide = false
	end
end

Connection = Key.Handle.Touched:Connect(Touched)

What we’re using is a Touched Event to detect changes for when the Tool’s Handle is being touched by another object via physics, and we can check the Hit parameter of the Object that got touched (Or Hit == LockedDoor)

Next up what we’re using is called a Connection to check this Touched Event, this nifty variable can let us set an Event to properly disconnect later inside the function at the right time (Or so that we don’t have to keep it firing over and over and over again, think of it as like a wire that’s connected to something then later cutting it to disconnect said wire)

If our if statement detects that the Hit is equal to our LockedDoor, then we can make our Door invisible to make it so the client (Or Player) can only see it!

Random Content

4 Likes