I wanted to change the value of a BoolValue that I use to turn music on or off. The value doesn’t change and instead, I got this error. The code and the error are attached down below! Thanks.
Hey, here is the local script. It does not include your latest edit (the edit in your reply).
local debounce = false
local RS = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local RSMUM = RS:WaitForChild("Music"):WaitForChild("UpdateMusic")
local RSMCMOn = RS:WaitForChild("Music"):WaitForChild("ChangeMusicOn")
local RSMCMOff = RS:WaitForChild("Music"):WaitForChild("ChangeMusicOff")
local musicstat = player:WaitForChild("Music"):WaitForChild("Music")
local start = RS:WaitForChild("Start")
local button = script.Parent
button.MouseButton1Click:Connect(function(plr)
if debounce == false then
debounce = true
if musicstat.Value == true then
RSMCMOff:FireServer(plr,musicstat)
button.Text = "Music: Off"
button.BackgroundColor3 = Color3.new(1, 0, 0)
elseif musicstat.Value == false then
RSMCMOn:FireServer(plr,musicstat)
button.Text = "Music: On"
button.BackgroundColor3 = Color3.new(0, 1, 0)
end
task.wait(0.25)
debounce = false
end
end)
Musicstat is equal to nil because you sending client stuff to the server that the result of Musicstat will become nil
Note that anything that sends from client to server like instance will be nil since it won’t replicate it. But UTF-8 characters won’t be nill since its not an instance
Also the mouse button1Click event doesn’t return player. It’s just a blank.
I guess so… I am going to try to access it directly from the server script using a PlayerAdded function. I thought it might have been better to just send it through a remote event so any localization error can be gone.
Yea I always forget that MouseButton1Click does not give the player.
Yea it works just fine, that’s what I thought about after you told me that I can’t use my initial idea. I just wanted to avoid any path-finding errors. Thanks.