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