So recently i got a placement system set up for my game and it works fine the only problem is i cant figure out how to get the script to figure out which player owns which plot and then only modify that plot. I tried to use remote events to communicate between the placement and the buyplot script but that didnt work at all.

--//Placement Script

local placementHandler = require(script:WaitForChild("PlacementModule"))
local base1 = workspace.Base1
local base2 = workspace.Base2
local base3 = workspace.Base3
local base4 = workspace.Base4
local items = game:GetService("ReplicatedStorage").Items
local plane = placementHandler.new(base4.Baseplate, base4.ItemHolder, 3)



local ItemOfChoice = "Model1"
local dummyModel 
local signal
local currentItemName
local function cancelPlacement()
	if (dummyModel) then
		plane:disable()
		if (dummyModel.Parent) then
			dummyModel:Destroy()
		end
		dummyModel:Destroy()
		dummyModel = nil
		signal = nil
		currentItemName = nil
	end
end
local function initiatePlacement(itemName)
	cancelPlacement()
	dummyModel = items[itemName]:clone()
	
	currentItemName = itemName
	
	for _, object in pairs(dummyModel:GetChildren()) do
		if(object:IsA("BasePart")) then
			object.CanCollide = false
		end
	end
	dummyModel.Parent = workspace
	
	local signal = plane:enable(dummyModel)


	signal:connect(function(location, model)
		game:GetService("ReplicatedStorage").ClientPlaced:FireServer(currentItemName, location)
		
		cancelPlacement()
	end)
end
wait(3)

initiatePlacement(ItemOfChoice)







	

BuyPlotScript

local plot = game.Workspace.Base4
local taken = false
local Owner = plot.Owner.Value
if Owner=="" then
	taken = false
else
	taken = true
end

script.Parent.Touched:connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
	local player = game.Players:FindFirstChild(hit.Parent.Name)
	if taken==true or game.Workspace.Base1.Owner.Value==player.name or game.Workspace.Base2.Owner.Value==player.name
	or game.Workspace.Base3.Owner.Value==player.name or game.Workspace.Base4.Owner.Value==player.name then
		print("You already own a plot or the current plot is already owned!")
	else
		game.Workspace.Base4.Owner.Value = player.name
		print(game.Workspace.Base4.Owner.Value)
		script.Parent.Parent:Destroy()
		taken= true
	end
	end
end)

Placement Server Side Script

local items = game:GetService("ReplicatedStorage").Items
game:GetService("ReplicatedStorage").ClientPlaced.OnServerEvent:connect(function(player, itemName, location)
	local itemTemplate = items:FindFirstChild(itemName)
	if (itemTemplate) then
		local item = itemTemplate:clone()
		item.Parent = workspace.Base.ItemHolder
		item:SetPrimaryPartCFrame(location[1])
	end
end)

If you guys could help me out on this problem it would mean alot to me Thanks!

7 comments

0

wait am i wrong or did you ask this question earlier / the other day?

0

He has asked it before, its been some time though.

0

Looks like it was deleted

0

Why does your if statement have like 50 conditions. Your code needs to be restructured immediately.

0

From lines 4 to 8, assuming the BuyPlotScript runs when the server begins, that segment will never change the value of "taken" to true. Unless you're disabling and re-enabling the script, try putting it in a loop

0

You should index the model with the player that joined or something

0

@incapaxx, there aren't that many conditions in the code given to us (7)