I am currently trying to make it so that when a player finishes a Tower, they get put on a table and then if they leave it will save.
Is this technologically possible?
I am currently trying to make it so that when a player finishes a Tower, they get put on a table and then if they leave it will save.
Is this technologically possible?
you can use touch event and then get the player who touched it and store it in a table, like this for example.
local part = workspace.Part -- this is the part that the player needs to touch to win
-- you have to change it to whatever part you want them to touch to win
local playertable = {} -- a new table where player who touch the part will be
-- inserted here
part.Touched:Connect(function(hit) --hit is basically what touched the part
if hit.Parent:FindFirstChild("Humanoid") then -- basically checks if it's a player that's touching it
--if then it's a player
local name = hit.Parent.Name -- gets the player name
table.insert(playertable, name) -- and now it's in the table
end
end)
Question: Will tables save on all servers? ( New and Modern )
oh, do you want it globally? then you need to use datastores, since this are for individual servers only
local DSService = game:GetService("DataStoreService")
local TouchDS = DSService:GetDataStore("TouchDS")
local part = workspace:WaitForChild("Part")
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local player = hit.Parent
local res = TouchDS:GetAsync(player.UserId)
if res and type(res) == "boolean" then
--player has already been recorded touching the part
else
local res = TouchDS:SetAsync(player.UserId, true)
end
end
end)
Thanks for the script! But can you explain how this works and also what I would need to do to make it so they can go through a door if they completed a tower? and make it so that for individual players, if they completed the tower a portal will be green and they can go through, but If they didn’t then they can’t go through and the teleporter color is red.
Sorry if that’s a lot.
Im still trying to learn about using Data stores but Im still very confused.