Script won't cancel itself from IntValue

Hello! I recently have been remaking a very old tycoon I made 2 years ago, and I have been trying to make a plot selection system. The selection system works perfectly except for detecting if the plot is occupied. I have been trying to make it tell the user if it’s occupied from the value in an InvtValue located in workspace, but it won’t work. Btw, there are three different plotnum InvtValues, the two in Workspace are what changes and what is detected if it is a certain number. I have tried everything I can think of but it won’t work, if you are able to help, that would be amazing!

Script (Localscript)

local taken = game.Workspace.plotnum
script.Parent.MouseButton1Click:Connect(function()
	taken = false
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.MyPlot.Value == script.Parent.Parent.Frame.plotname.plotnum.Value then
			taken = true
		end
	end
	if game.Workspace.plotnum.Value == 1 then
		script.Parent.Text = "Taken"
		wait(3)
		script.Parent.Text = "Select"
	else
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Plots[script.Parent.Parent.Frame.plotname.plotnum.Value].CFrame * CFrame.new(0,3,0)
		workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		game.Players.LocalPlayer.MyPlot.Value = script.Parent.Parent.Frame.plotname.plotnum.Value
		game.Workspace.plotnum.Value = 1
		script.Parent.Parent.Enabled = false
	end
end)

script.Parent.MouseButton1Click:Connect(function()
	if game.Workspace.plotnum2.Value == 2 then
		script.Parent.Text.Value = "Taken"
		wait(3)
		script.Parent.Text.Value = "Select"
	else
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Plots[script.Parent.Parent.Frame.plotname.plotnum.Value].CFrame * CFrame.new(0,3,0)
		workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		game.Players.LocalPlayer.MyPlot.Value = script.Parent.Parent.Frame.plotname.plotnum.Value
		game.Workspace.plotnum2.Value = 2
		script.Parent.Parent.Enabled = false
	end
end)

Location (Inside TextButton)
image
IntValue locations (plotnum & plotnum2)
image

Are you editing the values from a local script? Like, if you own a plot? If that’s the case, you cannot edit it on the client as it simple won’t replicate to the server, fire an event to change any values outside of the client objects. (UI’s as an example.)

Yes, whenever someone clicks select, the Localscript updates the IntValue in Workspace to 2. Then if someone else tries to select it, it wouldn’t let them due to the value being 2

it does update the value, but it still lets people Select it.

I edited my message to help with your most recent reply.

It only updates the value on the client, not on the server as I said. Local scripts do not replicate changes made to the server. You can see this for yourself if you test in server mode and look at the values before and after claiming the plot.

I am very bad with RemoteEvents and I am unsuccessful on getting that method to work
Script (ServerScriptService)


LocalScript (StarterPlayerScripts)

It wouldn’t be ScreenGui, it would be

Player.PlayerGui.TextButton.MouseButton1Click:Connect(function()

New problem, but I don’t understand what it means because I’m dumb

May you send the script so I can have a look?

Which script? It consists of 3 scripts. Sorry for the late response

The script with the error would be useful.

Nevermind, it isn’t important, I thought it was effecting it, but it isn’t I just removed a extra line and this appeared:


The script:

local taken = game.Workspace.plotnum
local remoteEvent = game:GetService("ReplicatedStorage").FireLol
script.Parent.MouseButton1Click:Connect(function()
	taken = false
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.MyPlot.Value == script.Parent.Parent.Frame.plotname.plotnum.Value then
			taken = true
		end
	end
	if game.Workspace.plotnum.Value == 1 then
		script.Parent.Text = "Taken"
		wait(3)
		script.Parent.Text = "Select"
	else
		-- give them the plot
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Plots[script.Parent.Parent.Frame.plotname.plotnum.Value].CFrame * CFrame.new(0,3,0)
		workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		game.Players.LocalPlayer.MyPlot.Value = script.Parent.Parent.Frame.plotname.plotnum.Value
		game.Workspace.plotnum.Value = 1
		script.Parent.Parent.Enabled = false
	end
end)

script.Parent.MouseButton1Click:Connect(function()
	if game.Workspace.plotnum2.Value == 2 then
		script.Parent.Text.Value = "Taken"
		wait(3)
		script.Parent.Text.Value = "Select"
	else
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Plots[script.Parent.Parent.Frame.plotname.plotnum.Value].CFrame * CFrame.new(0,3,0)
		workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		game.Players.LocalPlayer.MyPlot.Value = script.Parent.Parent.Frame.plotname.plotnum.Value
		remoteEvent:FireServer()
		game.Workspace.plotnum2.Value = 2
		script.Parent.Parent.Enabled = false
	end
end)

Remove .Value after .Text on lines 26 and 28.

It removed the errors in the console, but it still lets the user claim the plot when someone else already did. No errors pop up for any of the scripts now.

That is because you are not checking who owns the plot number or if someone owns that plot.

Oh, how do I fix this? I’m crappy at this type of stuff, so sorry

Most ideal case for you would be to make a folder for the plot, put an IntValue for the plot number and a BoolValue to be set to true if someone owns the plot meaning someone else cannot override it. Name the folder the players name.
Edit: I am not writing your script for you.
Edit 2: Going off to sleep, won’t be able to assist further. Good luck and someone else will return if you’re still struggling. Mark my post as the solution to your original post.

Saw another post with similar logic. Maybe this will apply: