Hi, so what I am having issues with is, I am creating a table, which is supposed to look for available hotels for my game(1 player per hotel), without having 2 players in the same hotel. My effort in trying to achieve this is quite confusing, as I add a BoolValue into the parts itself and name the value “Enabled.” The problem is, I’m not quite sure how to achieve this with the textbutton which has a localscript:
disabled = false
script.Parent.MouseButton1Click:connect(function()
if disabled == false then
disabled = true
game.Workspace.Teleport.RemoteFunction:InvokeServer()
wait(3)
disabled = false
end
end)
The thing is, I don’t know how to apply the table data to a button, for example if a localscript was inside a button and when you click it, it checks the table for hotels that are currently not taken (BoolValue = Enabled), and it looks through and chooses Point B and teleports you there. <— This is what I am trying to achieve, please help!
Inside the script, I made a table and I would use in pair loops but I’m not sure how to apply it using the textbutton, in other words, I’m not sure what to put in the localscript inside of the textbutton itself.
local SpawnTable = {game.Workspace.TeleportPart1,game.Workspace.TeleportPart2,game.Workspace.TeleportPart3,game.Workspace.TeleportPart4,game.Workspace.TeleportPart5,game.Workspace.TeleportPart6,game.Workspace.TeleportPart7,game.Workspace.TeleportPart8,game.Workspace.TeleportPart9,game.Workspace.TeleportPart10,game.Workspace.TeleportPart11,game.Workspace.TeleportPart12,game.Workspace.TeleportPart13,game.Workspace.TeleportPart14,game.Workspace.TeleportPart15}
game.Workspace.RemoteFunction.OnServerInvoke = function(player)
local selected
for i, v in pairs(SpawnTable) do
if v.Occupied.Value == false then
selected = v
break
end
end
if not selected then
return "Can't find an empty hotel!"
end
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = selected.Spawn.CFrame + Vector3.new(0,3,0)
return true
end
return "Can't find player HumanoidRootPart!"
end
also I messed around with some other settings, and fixed a couple errors but for some reason I can’t teleport to the actual part which I named “TeleportPart”