-
What do you want to achieve? So basically i have a world model and a table with every country of the world. In the world model there are different models with the name of the country. In these models there are some meshpart that form countries. Now i want that every tot seconds will be chosen a random country. the players will challenge eachothers and the one that will touch the country (the country is composed by a lot of meshparts) first will win.
-
What is the issue? So i tried to make a script, but there is a problem: when a player touches the mesh parts of a country composed by a single meshpart is ok, but if thecountry is composed by a lot of meshparts then the player have to touch all the meshparts of the country to win and i don’t want it! I want that the player can touch only one meshpart of the country model.
local FullTable = require(game.ServerScriptService.AllcountryWORLD)
local timerDuration = 10 -- Set your timer duration here
local FullArray = {}
local currentpart = nil
for key, value in pairs(FullTable) do
table.insert(FullArray, value)
end
local function startTimer(model)
print("Countdown started for " .. model.Name)
for count = timerDuration, 0, -1 do
print(count)
task.wait(1)
end
print("Countdown finished for " .. model.Name)
end
while true do
local randomIndex = math.random(1, #FullArray)
local mainModel = game.Workspace.World:FindFirstChild(string.lower(FullArray[randomIndex].Name:gsub(" ","")))
if mainModel then
for _, part in pairs(mainModel:GetDescendants()) do
if part:IsA("MeshPart") then
currentpart = part
if part == currentpart then
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
-- print("touchdetect")
if plr and part == currentpart then
print(plr.Name.. " Won!")
currentpart = nil
end
end
end)
end
end
end
startTimer(mainModel)
else
print(FullArray[randomIndex].Name.. " NOT FOUND! BE SURE THAT IT IS IN THE MODEL WORLD IN WORKSPACE!!!")
end
task.wait(timerDuration)
end
So i tried to make a table… and add the “currentparts” to the table and then check if in the table there is the part, but it sadly didn’t work…