Hello developers!
I’m making a on touch function to claim an area.
The onTouch function works perfectly but when I run my function, the script doesn’t find what I’m asking for.
This is my script:
game.ReplicatedStorage.Remotes.Claim1.OnServerEvent:Connect(function(plr)
local triggerParts = workspace["Map1 / Spawn"].TransparentParts:GetChildren()-- change to whatever you feel like, if this is a part remove the :GetChildren(), if it has lots of parts, keep :GetChildren()
local connection
connection = plr.Character.PrimaryPart.Touched:Connect(function() end)
local touchingParts = plr.Character.PrimaryPart:GetTouchingParts()
local inTrigger, triggerName = processTouchingParts(touchingParts)
connection:Disconnect()
if inTrigger == true then
print(plr.Name.."Is on a claim part", triggerName)
local area = workspace["Map1 / Spawn"].LeavesPlots:FindFirstChild(triggerName)
if area then
print("There is "..area.Name)
local occuped = area:WaitForChild("Occuped")
print("FindOccuped")
if not occuped.Value then
print("It's not occuped")
occuped.Value = true
print("It's now occuped")
area.PlayerName.SurfaceGui.TextLabel.Text = plr.Name
print("Name changed")
game.ServerStorage.ClaimFunction:FindFirstChild(triggerName).Value = plr.Name
print("We set the name of the plr into the good plot into the server storage")
local RegiveLeaves = plr.PlayerInfo.HipSize.Value
print(RegiveLeaves)
end
end
end
end)
This is the output issues (for prints debug)
Padrox_xIs on a claim part plot1
So triggerName = plot1.
This is the explorer:
I don’t understand why it doesn’t find the area and the “occuped” bool value…
Does anyone can help me to fix those problems !
If you have questions, ask them.