I am trying to make a tribe system, where you can create a tribe and other players can request to join it. If they want to join your tribe you must accept first.
But when Player1 creates a new tribe named "Tribe1" and then Player2 creates another tribe with the name "Tribe2" and Player2 requests to join "Tribe1" then the request doesn't prompt to Player1, who's the owner of the tribe, but it prompts to Player2
Here are some videos to show the problem:
Player1 creates Tribe 1 https://gyazo.com/2e7e3df0dbb98f7c6a30d99d104407a0
Player2 creates Tribe2 https://gyazo.com/045f9c9d1f196eaca937b7419d27bc26
Player2 tries to join Tribe1 and it prompts Player1, but player2 is the owner https://gyazo.com/2b026d21c97064a4a602579aee245078
Showing the owner values of the tribes https://gyazo.com/fe4bf8cb00ba7ac1bd0dd0a4fa8c6a42
Here's my code:
Script 1, local script
local event = game.ReplicatedStorage:WaitForChild("TribeUpdater")
local remoteFunc = game.ReplicatedStorage:WaitForChild("JoinTribeRequest")
local currentTribe
event.OnClientEvent:Connect(function(tribe)
local tribeButton = Instance.new("TextButton")
tribeButton.Size = UDim2.new(0.919, 0, 0.07, 0)
tribeButton.BackgroundColor3 = tribe.TeamColor.Color
tribeButton.Text = tribe.Name
tribeButton.TextScaled = true
tribeButton.Parent = script.Parent
currentTribe = tribe
tribeButton.MouseButton1Up:Connect(function()
remoteFunc:InvokeServer(currentTribe)
end)
end)
Script 2, server script
local remoteFunc = game.ReplicatedStorage:WaitForChild("JoinTribeRequest")
local bindable = game.ReplicatedStorage:WaitForChild("AcceptDeny")
local bindable2 = game.ReplicatedStorage:WaitForChild("AcceptDeny2")
local ownerValue = script.owner
local function teamAssign(plr, tribe)
ownerValue.Value = nil
repeat
ownerValue.Value = tribe.Owner.Value
until ownerValue
bindable:Fire(ownerValue.Value, plr.Name)
bindable2.Event:Connect(function(isAccepted)
repeat
if isAccepted then
plr.Team = tribe
break
end
until isAccepted ~= nil
end)
end
remoteFunc.OnServerInvoke = teamAssign
Script3, also server script:
local bindable = game.ReplicatedStorage:WaitForChild("AcceptDeny")
local bindable2 = game.ReplicatedStorage:WaitForChild("AcceptDeny2")
local message = " would like to join your tribe"
local label = script.Parent.TextLabel
local function joinTribeReq(owner, plr)
print(owner)
if owner == script.Parent.Parent.Parent.Parent then
script.Parent.Visible = true
label.Text = plr..message
script.Parent.Accept.MouseButton1Up:Connect(function()
script.Parent.Visible = false
bindable2:Fire(true)
end)
script.Parent.Deny.MouseButton1Up:Connect(function()
script.Parent.Visible = false
bindable2:Fire(false)
end)
end
end
bindable.Event:Connect(joinTribeReq)
If you have any questions or want to see anything else just ask!
