I am trying to make a system for the cash register where the player is able to unclaim it. When I added the unclaim button, I want a text label visibility on a surface gui to be false and the visibility of a button to be true. However, when I did it on a server script, the visibility of the text label is still true and the text button visibility is true which isn’t what I want. May I know what is wrong and how to fix it? My script works on the person who pressed the button to unclaim a cash register but not for everyone else. I tried using remote events but it doesn’t seem to work.
Script on a button (Local script)
local button = script.Parent
local player = game.Players.LocalPlayer
local tweenservice = game:GetService("TweenService")
local screens = game.Workspace:WaitForChild("Screens")
button.MouseButton1Click:Connect(function()
local stuff = screens:GetDescendants()
for i,v in pairs(stuff) do
if v:IsA("StringValue") and v.Value == player.Name then
v.Parent.Visible = false
v.Parent.Parent.TextButton.Visible = true
if v.Parent.Parent.Parent.Parent.Name == "Screen1" then
game.ReplicatedStorage.Changevalue1:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen2" then
game.ReplicatedStorage.Changevalue2:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen3" then
game.ReplicatedStorage.Changevalue3:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen4" then
game.ReplicatedStorage.Changevalue4:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen5" then
game.ReplicatedStorage.Changevalue5:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen6" then
game.ReplicatedStorage.Changevalue6:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen7" then
game.ReplicatedStorage.Changevalue7:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen8" then
game.ReplicatedStorage.Changevalue8:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen9" then
game.ReplicatedStorage.Changevalue9:FireServer(v)
elseif v.Parent.Parent.Parent.Parent.Name == "Screen10" then
game.ReplicatedStorage.Changevalue2:FireServer(v)
end
local tweeninfo = TweenInfo.new(1,Enum.EasingStyle.Bounce)
local goals = {Position = UDim2.new(0.42, 0,1, 0)}
local tween = tweenservice:Create(button,tweeninfo,goals)
tween:Play()
end
end
end)
Server script
game.ReplicatedStorage.Changevalue1.OnServerEvent:Connect(function(player,v)
print(v.Name)
v.Parent.Visible = false
v.Parent.Parent.TextButton.Visible = true
v.Value = ""
end)