#Making A Door Respond to Just One Player/User
1 messages · Page 1 of 1 (latest)
i already have the model/script that makes it open
but i dont know how to limit it for only one person to be able to do it
Wait so you want it to be client sided?
Well, technically server scripts already do that
wdym? (sorry im not really good at coding, just making a game for me and my freinds)
just add a gaurd clause
Like if you make a normal door script it should open for everyone if one player opens it
no like its restricted for everyone else to use but the player i want that is allowed to use it
Specific player then?
so would that player be a specific person? like you want someones name?
yea
send the code rq i got u
code?
oh have u not made any?
welll youd basically just add whats call "Guard Clause"
if player.Name ~= "ThisName" then return end
too big?
no word limits
only send the part about the door
yea thats what i did
like im pressing enter
or anything?
uhh
nah theres no function
oh dear 😭
send that function
local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
If so, it's better to use collection service
local TweenService = game:GetService("TweenService")
local hinge = script.Parent.PrimaryPart
local prompt = script.Parent.Base:FindFirstChildOfClass("ProximityPrompt")
local Sound = nil
if script.Parent.Base:FindFirstChildOfClass("Sound") then
Sound = script.Parent.Base:FindFirstChildOfClass("Sound")
end
local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
prompt.Triggered:Connect(function()
prompt.Enabled = false
if prompt.ActionText == "Close" then
tweenClose:Play()
prompt.ActionText = "Open"
else
tweenOpen:Play()
prompt.ActionText = "Close"
end
if Sound ~= nil then Sound:Play() end
wait(1)
prompt.Enabled = true
end)
^^^^ this
But youre pretty new so dont be afraid to make sum abit less efficient
is this in a local script btw?
a blue one
nah
prompt.Triggered:Connect(function(playerWhoTriggered)
if playerWhoTriggered.Name ~= "Error_Code987654321" then return end
prompt.Enabled = false
if prompt.ActionText == "Close" then
tweenClose:Play()
prompt.ActionText = "Open"
else
tweenOpen:Play()
prompt.ActionText = "Close"
end
if Sound ~= nil then Sound:Play() end
wait(1)
prompt.Enabled = true
end)
FYI
if that player opens the door
other ppl can still walk in
local TweenService = game:GetService("TweenService")
local hinge = script.Parent.PrimaryPart
local prompt = script.Parent.Base:FindFirstChildOfClass("ProximityPrompt")
local Sound = nil
if script.Parent.Base:FindFirstChildOfClass("Sound") then
Sound = script.Parent.Base:FindFirstChildOfClass("Sound")
end
local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
prompt.Triggered:Connect(function(playerWhoTriggered)
if playerWhoTriggered.Name ~= "Error_Code987654321" then return end
prompt.Enabled = false
if prompt.ActionText == "Close" then
tweenClose:Play()
prompt.ActionText = "Open"
else
tweenOpen:Play()
prompt.ActionText = "Close"
end
if Sound ~= nil then Sound:Play() end
wait(1)
prompt.Enabled = true
end)
kk
work?
and would i be able to do the same with my other friends? like when i make a door for them
nah i first gotta get my friend ingame
would each friend get a dif door?
yea
just replace that name?
the playes name
if playerWhoTriggered.Name ~= "Error_Code987654321"
and ima amke this 1 script work for infinite doors
rq
@safe isle
can u add me to studio?
?
hol on wait
add me to team create
😭
anyways
add me to team create
i added u
i friended u back
This is funny
hm?
@safe isle store yor scripts on the server 🙏
im new to scripting 😭 dont judge
i cant tell where scripts go
wheres that
shit i cant find it either lol
yea they removed it
i forgot
they thought it was useless
because most ppl use discord
yea
make the names of those, the player that can open the door
k 1 more min
also
since you put the script in server script service
primary part had an error
i wasnt done 😭
now all u have to do is add a new door and change the prompt name
@safe isle make yourself a door and test it
didnt work
goes inside the doors model
has to be put into there?
yes
bet lol
friend me on dc rq so u can ask for help anytime @safe isle