CanSpectate.Changed:Connect(function(Value)
if Value == true then
print("visible")
script.Parent.Visible = true
else
if Value == false then
print("not visible")
script.Parent.Visible = false
end
end
end)
i also tried
CanSpectate:GetPropertyChangedSignal("Value"):Connect(function()
if CanSpectate.Value == true then
print("visible")
script.Parent.Visible = true
else
if CanSpectate.Value == false then
print("not visible")
script.Parent.Visible = false
end
end
end)
type or paste code here
both of them dosent work . i changed the value from serverside script
Can you please put a print statement before and after the .Changed function
i.e.
print("BEFORE")
CanSpectate:GetPropertyChangedSignal("Value"):Connect(function()
if CanSpectate.Value == true then
print("visible")
script.Parent.Visible = true
else
if CanSpectate.Value == false then
print("not visible")
script.Parent.Visible = false
end
end
end)
print("AFTER")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Promise = require(ReplicatedStorage:WaitForChild("Modules"):FindFirstChild("Promise"))
local CanSpectate = ReplicatedStorage:WaitForChild("Values"):FindFirstChild("CanSpectate")
local button = script.Parent
local spectateframe = button.spectate_frame
local playername = button.spectate_frame:FindFirstChild("player_name")
local openNow = true
local position = 1
local player_list = {}
local currentCamera = workspace.CurrentCamera
CanSpectate:GetPropertyChangedSignal("Value"):Connect(function()
if CanSpectate.Value == true then
print("visible")
script.Parent.Visible = true
else
if CanSpectate.Value == false then
print("not visible")
script.Parent.Visible = false
end
end
end)
local function updatePlayerList(exemptPlayer)
Promise.new(function(resolve,reject)
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= exemptPlayer and not table.find(player_list,v) then
table.insert(player_list,v)
end
end
end):catch(warn)
end
local function updateCamera(playerSubject)
Promise.new(function(resolve,reject)
playername.Text = tostring(playerSubject)
currentCamera.CameraSubject = playerSubject.Character
end):catch(warn)
end
updatePlayerList()
game:GetService("Players").PlayerAdded:Connect(function()
updatePlayerList()
end)
game:GetService("Players").PlayerRemoving:Connect(function(plr)
updatePlayerList(plr)
end)
button.MouseButton1Up:Connect(function()
if openNow == true then
openNow = false
spectateframe.Visible = true
position = 1
updateCamera(player_list[1])
else
openNow = true
spectateframe.Visible = false
updateCamera(game:GetService("Players").LocalPlayer)
end
end)
button.spectate_frame.left.MouseButton1Up:Connect(function()
position = position -1
if position <1 then
position = #player_list
end
updateCamera(player_list[position])
end)
button.spectate_frame.right.MouseButton1Up:Connect(function()
position = position +1
if position > #player_list then
position = 1
end
updateCamera(player_list[position])
end)