So I made a script for a door to open, it’s supposed to open only when I (or anyone else if I put their name) want it to open,
The problem is that for some reason it just doesn’t detect correctly if it’s me or any other player. It doesn’t give errors or anything, it just opens when ANYONE triggers the proximity prompt.
I’ve searched for solutions for some hours and I couldn’t find anything, I even looked for similar scripts and I didn’t see a difference.
Script (have in mind “proximityprompt” is a variable, and yes it works):
proximityprompt.Triggered:Connect(function(plr)
if plr.Name == "Epixerty" then
if debounce == false then
debounce = true
openplay:Play()
mainpart.CanCollide = false
wait(2)
closeplay:Play()
wait(0.5)
mainpart.CanCollide = true
debounce = false
end
end
end)
local plrID = -- put the user id here
local locplr = game:GetService("Players").LocalPlayer
debounce = false
proximityprompt.Triggered:Connect(function()
if debounce == false and locplr.UserId == plrID then
openplay:Play()
mainpart.CanCollide = false
wait(2)
closeplay:Play()
wait(0.5)
mainpart.CanCollide = true
debounce = false
end
end)
The segment of the script you provided is fine (and works), you need to share the entire script or at least the parts relevant to this segment, i.e; the definition of the function named “closeplay” and the declaration of the variable “mainpart”.
thanks, I knew I could use UserId but I was lazy to actually copy my ID so I just used my username. I don’t know why and it could be a roblox issue, but thank you for your help