Plot won't be claimed after talking to NPC

I have a system where you claim a plot and progress through the game etc. but the problem is the plot won’t be claimed after you talk to the NPC. It does claim when you don’t talk to the NPC though. No errors
Here’s the part of my script that controls talking to the NPC:

local Prompt = TutorialGuy:WaitForChild("TutorialGuy"):WaitForChild("ProximityPrompt")
local DialogueMod = require(game:WaitForChild("ReplicatedStorage"):WaitForChild("DialogueModule"))
		Prompt.Triggered:Connect(function(plr)
			local CurrentData = GameData:GetAsync(Player.UserId .. "GameData") --GameData is the DataStore for my game
			if plr == Player then
				if CurrentData["DidTutorial"] == false then
					DialogueMod:Start(plr, "DaBoy", Prompt.Parent.Parent:WaitForChild("Focus"), {"Hello there!", "I am the Floating Head, and I am here to guide you.", "To start this game, you must first claim a plot.", "After that, you have multiple tools to create any accessory you like.", "When you are done making your accessory, you can save it and add it to your store, where people can buy it for coins or robux.", "Mind you, it costs 100 coins to add an accessory to your store.", "Here, I'll give you 500 coins.", "Now, good luck on your accessories!"}, true, 15, Prompt, "Tutorial")
					CurrentData["DidTutorial"] = true
					PointToTutorial:FireClient(Player, false)
					DialogueMod.Ended:Connect(function(player, key)
						print("Received on server")
						if player == plr then
							print("Went through stage 1")
							print(player)
							print(key)
							if key == "Tutorial" then
								print("Went through stage 2")
								CurrentData["Coins"] = CurrentData["Coins"] + 500
								GameData:SetAsync(Player.UserId .. "GameData", CurrentData)
								local UpdateCoinUI = ServToPlr:WaitForChild("UpdateCoins")
								UpdateCoinUI:FireClient(plr, CurrentData["Coins"])
								print("Updated UI")
							end
						end
					end)
				else
					DialogueMod:Start(plr, "DaBoy", Prompt.Parent.Parent:WaitForChild("Focus"), {"FillerText", "MoreFillerText", "EVENMOREFILLERTEXT"}, true, 15, Prompt, "regular")
				end
			end
		end)

And here’s the script that checks when the prompt is triggered (Doesn’t print “Triggered” if plot is claimed after tutorial)

local PlotVal = script.Parent:WaitForChild("PlotVal")
local Players = game:GetService("Players")
local ServStor = game:GetService("ServerStorage")
local Events = ServStor:WaitForChild("Misc"):WaitForChild("Events")
local Prompt = script.Parent
local Plot = Prompt.Parent
local Owner
Prompt.Triggered:Connect(function(plr)
	print("Triggered")
	Owner = plr
	Prompt.Parent = game:GetService("ServerStorage")
	local Claim = Events:WaitForChild("ClaimPlot")
	Claim:Fire(PlotVal.Value, plr)
	print("After fire code fired")
end)
Players.PlayerRemoving:Connect(function(plr)
	if plr == Owner then
		Owner = nil
		Prompt.Parent = Plot
	end
end)

I have a game file if you want the entire game:
Make And Wear.rbxl (91.6 KB)

If you need anything else let me know. Thanks

local Prompt = TutorialGuy:WaitForChild(“TutorialGuy”):WaitForChild(“ProximityPrompt”)
local DialogueMod = require(game:WaitForChild(“ReplicatedStorage”):WaitForChild(“DialogueModule”))
Prompt.Triggered:Connect(function(plr)
local CurrentData = GameData:GetAsync(Player.UserId … “GameData”) --GameData is the DataStore for my game
if plr == Player then
if CurrentData[“DidTutorial”] == false then
DialogueMod:Start(plr, “DaBoy”, Prompt.Parent.Parent:WaitForChild(“Focus”), {“Hello there!”, “I am the Floating Head, and I am here to guide you.”, “To start this game, you must first claim a plot.”, “After that, you have multiple tools to create any accessory you like.”, “When you are done making your accessory, you can save it and add it to your store, where people can buy it for coins or robux.”, “Mind you, it costs 100 coins to add an accessory to your store.”, “Here, I’ll give you 500 coins.”, “Now, good luck on your accessories!”}, true, 15, Prompt, “Tutorial”)
CurrentData[“DidTutorial”] = true
PointToTutorial:FireClient(Player, false)
DialogueMod.Ended:Connect(function(player, key)
print(“Received on server”)
if player == plr then
print(“Went through stage 1”)
print(player)
print(key)
if key == “Tutorial” then
print(“Went through stage 2”)
CurrentData[“Coins”] = CurrentData[“Coins”] + 500
GameData:SetAsync(Player.UserId … “GameData”, CurrentData)
local UpdateCoinUI = ServToPlr:WaitForChild(“UpdateCoins”)
UpdateCoinUI:FireClient(plr, CurrentData[“Coins”])
print(“Updated UI”)
end
end
end)
else
DialogueMod:Start(plr, “DaBoy”, Prompt.Parent.Parent:WaitForChild(“Focus”), {“FillerText”, “MoreFillerText”, “EVENMOREFILLERTEXT”}, true, 15, Prompt, “regular”)
end
end
end)

local PlrClaimedPlots = ServToPlr:WaitForChild(“ClaimedPlot”)
local Plot = workspace.PlotToClaim
local PlotClaim = Plot:WaitForChild(“Claim”)
local CFrameToSpawn = CFrame.new(0,0,0)
local PlotSpawner = workspace:WaitForChild(“PlotSpawner”)
local plotSpawned = Instance.new(“BoolValue”)
plotSpawned.Name = Player.Name … “PlotClaimed”
plotSpawned.Parent = Plot
PlrClaimedPlots.OnClientEvent:Connect(function(plr)
print(“Triggered”)
if plotSpawned.Value == false then
print(“PlotSpawned is false”)
if plr == Player then
print(“Player is the same as the player who is trying to claim the plot”)
plotSpawned.Value = true
print(“PlotSpawned is now true”)
CFrameToSpawn = Plot.CFrame + Vector3.new(0, Plot.Size.Y/2, 0)
print(“Spawning plot”)
local ClaimedPlot = PlotSpawner:Clone()
ClaimedPlot.Parent = workspace
ClaimedPlot.CFrame = CFrameToSpawn
ClaimedPlot.BrickColor = BrickColor.new(“Bright red”)
ClaimedPlot.Size = Vector3.new(2.5, 0.25, 2.5)
ClaimedPlot.Anchored = true
ClaimedPlot.Name = “ClaimedPlot”
local PlotClaimed = Instance.new(“BoolValue”)
PlotClaimed.Name = “PlotClaimed”
PlotClaimed.Value = true
PlotClaimed.Parent = ClaimedPlot
Plot.Parent = nil
print(“Placed plot”)
else
print(“Player is not the same as the player who is trying to claim the plot”)
end
else
print(“PlotSpawned is true”)
end
end)
PlotClaim.ClickDetector.MouseClick:Connect(function(plr)
if plr == Player then

2 Likes

Thanks, but I already fixed it way before you replied while waiting. Apparently it was something about anchoring the player’s humanoid root part. Thanks again for replying

Oh okay I see how it is I give and I give an you take.

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