Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

make a door open when value reaches a specific number?

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()


3 comments

0

Please be more descriptive i dont understand the issue nor how to solve it

0

Is this a script inside the door in workspace?

0

yes thi script is inside the door

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.