Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make an FE door lock system?

Asked by
iEggQ 0
4 years ago

Hi all, I would like to figure out how to do a door lock system like the one in "Welcome to the Town of Robloxia" and I wanted to know how I would go about checking if the player is the owner if the house (i.e. the player name is in the model name) and I have a button I click with the following code that is used for the lock button:

local ValueFetchSystem = game.ReplicatedStorage:FindFirstChild("DoorLockSystem")
local ModeEnabled = script.Parent.ToggleLock        

function onButtonClicked()
    if script.Parent.Text == "Lock House Doors" then
        script.Parent.Text = "Unlock House Doors"
        ModeEnabled.Value = true
    elseif script.Parent.Text == "Unlock House Doors" then
        script.Parent.Text = "Lock House Doors"
        ModeEnabled.Value = false
    end
end

script.Parent.MouseButton1Click:connect(onButtonClicked)

ValueFetchSystem.OnClientInvoke = function()
    return ModeEnabled.Value
end

and I'm trying to set the value of ModeEnabled (aka collision true or false) as the value for my door's can-collide value, I'm really stuck and i really need some help, all help is very much appreciated

P.S. here are some more scripts involved:

local ValueFetchSystem = game.ReplicatedStorage:FindFirstChild("DoorLockSystem")

local function IsCollidable(value)
    print(value)
end

ValueFetchSystem:InvokeClient(IsCollidable)

Also I am new to advanced ROBLOX programming so I apologize for my obvious noobish code

Original Filtering Disabled script in Welcome to the Town of Robloxia:

function onButtonClicked()
local x = game.Workspace:FindFirstChild("Home"..script.Parent.Parent.Parent.Parent.Name)
if not (x) then
return
else
if script.Parent.Text == "Lock House Doors" then
script.Parent.Text = "Unlock House Doors"
x.Home.FDoor.CanCollide = true
x.Home.BDoor.CanCollide = true
x.Home.GDoor.CanCollide = true
elseif script.Parent.Text == "Unlock House Doors" then
script.Parent.Text = "Lock House Doors"
x.Home.FDoor.CanCollide = false
x.Home.BDoor.CanCollide = false
x.Home.GDoor.CanCollide = false
end
end
end
script.Parent.MouseButton1Click:connect(onButtonClicked)

Answer this question