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

make a door open when value reaches a specific number?

Asked by 3 years ago

i have a door that i want to destroy itself once intvalue reaches 10 or higher but i have a problem on doing so i don't know what is the problem here is the script:

local int_value = game.StarterPack.Pizza.IntValue
local pizza = game.StarterPack.Pizza

int_value.Changed:Connect(function()
if int_value.Value = int_value.Value  --I want to type equal to or greater than 10 but dont know hw
script.Parent:Destroy()


0
Please be more descriptive i dont understand the issue nor how to solve it Galaxybombboy 134 — 3y
0
Is this a script inside the door in workspace? Galaxybombboy 134 — 3y
0
yes thi script is inside the door Mantery123 9 — 3y

1 answer

Log in to vote
0
Answered by
Roox4 21
3 years ago

This script should work:

First put a Remote Event in your ReplicatedStorage.

This is a local script that should be in StarterPlayerScripts:

local door = workspace.Door
local intValue = game.StarterPack.Value

local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

intValue.Changed:Connect(function()
    if intValue.Value >= 10 then
        event:FireServer("destroy")
    end
end)

And this is a script that should be in ServerScriptService:

local door = workspace.Door
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

event.OnServerEvent:Connect(function(player, ...)
    local tuple = {...}
    if tuple[1] == "destroy" then
        door:Destroy()
    end
end)
Ad

Answer this question