The script receives the command, I have checked with prints and other stuff it should do. BUT it just doesn’t activate the value. Script:
local RemotesFolder = game.ReplicatedStorage:WaitForChild("ComputerEvents")
local Tower2 = workspace.Tower2
local Activated = Tower2.Activated.Value
local UserActivated = Tower2.UserActivated.Value
RemotesFolder.TowerManage.OnServerEvent:Connect(function(player,WhoActivated)
if WhoActivated == "user" then
if not UserActivated and not Activated then
print("1")
UserActivated = true
print("2")
workspace.Interface.Interface.ClickDetector.MaxActivationDistance = 5
activate:Play()
for i, v in pairs(Tower2:GetChildren()) do
if v.Name == "Neon" then
v.BrickColor = BrickColor.new("Royal purple")
end
end
wait(activate.Length)
idle:Play()
elseif UserActivated and not Activated then
Error()
elseif not UserActivated and Activated then
Error()
end
elseif WhoActivated == "dev" then
end
end)
Because that local variable is just a copy of that true/false value. When you change it you just change the value of your local UserActivated variable. It won’t change the value of TowerTwo.UserActivated.Value
To change the value of that you need to use
TowerTwo.UserActivated.Value = true
I think the code is about as short as it can be, looks good to me. You can’t set UserActivated.Value because UserActivated is your local true/false variable, it has no value, so it must stay as Tower2.UserActivated.Value = true
Unless, as I think you just said if you change it to be
local UserActivated = Tower2.UserActivated
Then you can say
UserActivated.Value = true
but everywhere else you change to say If UserActivated.Value == false.
That works too
The only thing I’d suggest, IF you have lots of towers (I’m only guessing this because the tower here is called Tower2, so there might be Tower1, Tower3, etc. etc.) would be to do something so you don’t repeat this code for each tower, but with different Tower1,Tower2,Tower3 put in.