Hello! Well, I have a keycard door that is with a proximity prompt for a game of obstacles but to make it more personalized then… there would be a way to make the user who interacted with the door open only for him? so as to prevent other players from taking advantage
You can just use a LocalScript so the door opening is only on client side.
So the script that currently handles the door should pass it to a localscript?
Yes, you could pass information via a remote event:
local event = --event path
local prox = --proximity prompt path
prox.Triggered:Connect(function(p)
event:FireClient(p)
end
Then open the door in the LocalScript.
And how would I pass it through a remote event? Would I have to combine it with the door script or something like that?
No, you create a remote event and make a localscript in the same door that opens the door when the event is fired.
You’d have to open the door on the client of the player.
Localscripts don’t work in Workspace. Put a localscript in StarterGui to handle the door events.
game.ReplicatedStorage.Remote_Event.OnClientEvent:Connect(function()
local door = Door_Here
--script the opening thing here
end)
It must be: A localscript in StarterGui, StarterPack, or any StarterPlayer stuff.
Server sends remote to the localscript.
Okey but how would you make a script like this? And the script that it has, what makes the door open, should I leave it as a script or change it to a local script?
If you want the door to only open for the person who completed the challenge, just use a Local Script. Also, to open the door, you can animate it or just set Can Collide and Transparency to false and 1.
You’d have to use a local script and then for example change the door’s transparency to 1. The transparency will only change for the player because the value was changed on a local script and not a server script.
I mean, I already have everything, the door opens correctly with a specific object, all through proximity prompt, only when doing this action I would like the door to open only for the player who interacted with it
My door occupies TweenService so I don’t think the transparency thing applies in my case
Use a local script like this:
local event = --event path
local door = --door path
event.OnClientEvent:Connect(function()
door.Transparency = 1
door.CanCollide = false
end
Can you show us the script please?
This is the script
local TweenService = game:GetService(‘TweenService’)
local time = 2
script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
if Player.Character:FindFirstChild(‘Tool’) then
print(“Found KeyCard!”) – this will print if it finds the keycard
script.Parent.ProximityPrompt.Enabled = false
TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo.new(time,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.RotateDoor.Position, Orientation = script.Parent.Parent.RotateDoor.Orientation}):Play()
wait(time + time)
TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo.new(time,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.ReferDoor.Position, Orientation = script.Parent.Parent.ReferDoor.Orientation}):Play()
wait(time)
script.Parent.ProximityPrompt.Enabled = true
end
end)
Basically that is script that opens the door
Is it a server script? (char 30)
Just insert the event path, fire the event right after
print(“Found KeyCard!”) – this will print if it finds the keycard
then move all the tweening bits and the proximity prompt disable and enable to a LocalScript parented to the same object as your ServerScript.
and how would the event be so that there is no error in the script