I want to make a door. When boolvalue name “AllowOpen” is true, the door opens when you touch it.
The problem is I tried to set boolvalue from true to false. Which activate the neons color. And it keeps getting the same result.
ServerScripts:
local tweenservice = game:GetService("TweenService")
local runservice = game:GetService("RunService")
local info = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local touched = false
local AllowOpen = script.Parent.AllowOpen
local HeartBeat
HeartBeat = runservice.Heartbeat:Connect(function ()
for i, door in pairs(script.Parent.Parent.D1:GetDescendants()) do
if door:IsA("Part") and door.Name == "NeonActivator" then
if not touched then
if AllowOpen.Value == true then
local t = tweenservice:Create(door, TweenInfo.new(.5), {Color = Color3.fromRGB(116, 166, 118)})
t:Play()
else
local f = tweenservice:Create(door, TweenInfo.new(.5), {Color = Color3.fromRGB(166, 166, 166)})
f:Play()
end
end
end
end
end)
local function Open_door(hit)
for i, door in pairs(script.Parent.Parent.D1:GetDescendants()) do
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and AllowOpen.Value == true then
HeartBeat:Disconnect()
script.Parent.CanTouch = false
if door:IsA("Part") then
local opentween = tweenservice:Create(door, info, {Position = door.Position + Vector3.new(0,10,0)})
opentween:Play()
end
if door:IsA("Part") and door.Name == "NeonActivator" then
local opentween = tweenservice:Create(door, TweenInfo.new(.5), {Color = Color3.fromRGB(206, 90, 90)})
opentween:Play()
end
end
end
end
script.Parent.Touched:Connect(Open_door)
I tried using something like .Changed and GetPropertyChangedSignal() and I’m still confuse with those things. Could you give me an example or a short script that will make me understand easier?