Value not changing

I’m attempting to change a value via a script from ServerScriptService but it doesn’t change, strangely when I print the value it shows it has changed but it doesn’t show it in the workspace.

local event = game:GetService("ReplicatedStorage").StartRound
local eventD = game:GetService("ReplicatedStorage").Death
local eventD2 = game:GetService("ReplicatedStorage").Death2
local kill = game:GetService("ReplicatedStorage").Kill
repstor = game:GetService("ReplicatedStorage")
local isround = game.Workspace.GlobalVariables.IsRound.Value

event.OnServerEvent:Connect(function()
	isround = "Yes"
	print(isround)
	local storage = game:GetService("ServerStorage")
	local tools = storage.Tools

	local function randomMurder()
		local players = game:GetService("Players"):GetPlayers()
		selectedMurd = players[math.random(1,#players)]
		return selectedMurd
	end

	local function randomSheriff()
		local players = game:GetService("Players"):GetPlayers()
		selectedSher = players[math.random(1,#players)]
		return selectedSher
	end
	-- Pick a Murderer
	randomMurd = randomMurder()
	print(randomMurd)
	if randomMurd and randomMurd.Character then
		randomMurd.Character.Variables.Role.Value = "Murderer"
		local inv = randomMurd.Backpack
		local clone = tools.Knife:Clone()
		clone.Parent = inv
	end
	-- Pick a Sheriff
	repeat
	wait(1)
	randomSher = randomSheriff()
	print(randomSher)
	until randomSher ~= randomMurd or isround == "No"
	if randomSher and randomSher.Character then
		randomSher.Character.Variables.Role.Value = "Sheriff"
		local inv = randomSher.Backpack
		local clone = tools.Revolver:Clone()
		clone.Parent = inv
	end
	-- Make everyone else an Innocent
	local players = game:GetService("Players"):GetPlayers()
	for _, player in ipairs(players) do
		player.Character.Variables.Role.Value = "Innocent"
	end
end)

image_2023-08-26_133528146
image_2023-08-26_133537611

Mines doing the same thing and I was about to post why my number value wasnt changing.

1 Like

I strongly recommend not even using a value at all, you’re already using remote events, use these to transmit data from server to client and back.

are you talking about the “isRound” value not being changed?

Both the isRound value and the role values are not changing.

You defind IsRunning variable to number not property of instance so you can detect.

local isround = game.Workspace.GlobalVariables.IsRound.Value

then you set IsRunning to “yes” not changing property of Numbervalue
so if you did do this

local isround = game.Workspace.GlobalVariables.IsRound.Value
print(typeof(isround))-- number not instance

it will be always number not property of NumberValue
Chaneg it to

...
local isround = game.Workspace.GlobalVariables.IsRound

event.OnServerEvent:Connect(function()
	isround.Value = "Yes"
....
2 Likes

I’ve got a cool resource for ya.
https://www.lua.org/manual/

7 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.