Alright, heres the scripts:
local script inside a gui
script.Parent.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
script.Parent.Text = "OPTED OUT"
script.Parent.BackgroundTransparency = 0
local value = false
local de = true
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("sendopt")
script.Parent.MouseButton1Click:Connect(function(click)
if de == true then
de=false
if script.Parent.Text == "OPTED OUT" and script.Parent.BackgroundColor3 == Color3.fromRGB(170, 0, 0) then
script.Parent.Text = "OPTED IN"
script.Parent.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
value = true
remoteEvent:FireServer()
print("fired")
else
script.Parent.Text = "OPTED OUT"
script.Parent.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
value = false
remoteEvent:FireServer()
print("fired")
end
wait(4)
de = true
end
end)
serverscript, inside serverscriptservice
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteFunction = ReplicatedStorage:WaitForChild("requestvalue")
local remoteFunctionrt = ReplicatedStorage:WaitForChild("requestnew")
local remoteEventopt = ReplicatedStorage:WaitForChild("sendopt")
local remoteEventwait = ReplicatedStorage:WaitForChild("waitinglol")
local remoteEventweare = ReplicatedStorage:WaitForChild("waiting")
local roundval = game.ServerScriptService.isround.Value
local function createPart(roundval)
local roundval = game.ServerScriptService.isround.Value
return roundval
end
local valuelol = game.ServerScriptService.new.Value
local function returnvals(valuelol)
local valuelol = game.ServerScriptService.new.Value
return valuelol
end
local function changeopt(player)
if player:GetAttribute("Opted") == true then
player:SetAttribute("Opted", false)
print("false")
else
player:SetAttribute("Opted", true)
print("true")
end
end
local function plrwaiting(player)
if player:GetAttribute("playing") == true then
player:SetAttribute("playing", false)
else
player:SetAttribute("playing", true)
end
end
local function waitingbefore(player)
for _, player in ipairs(game.Players:GetPlayers()) do
if player:GetAttribute("playing") == true then
script.waiitng.Value = script.waiitng.Value + 1
local value = script.waiitng.Value
remoteEventwait:FireAllClients(value)
end
end
end
local function wearewaiting(player)
waitingbefore()
end
remoteFunction.OnServerInvoke = createPart
remoteFunctionrt.OnServerInvoke = returnvals
remoteEventopt.OnServerEvent:Connect(changeopt)
remoteEventwait.OnServerEvent:Connect(plrwaiting)
remoteEventweare.OnServerEvent:Connect(waitingbefore)
Heres just the important part in the serverscript:
local function changeopt(player)
if player:GetAttribute("Opted") == true then
player:SetAttribute("Opted", false)
print("false")
else
player:SetAttribute("Opted", true)
print("true")
end
end
the whole local script is important.
The print in the local script works just fine, while the print in the serverscript does not.
no errors
Thanks for your help!!