Try modifying your code to this:
local plr = game:GetService("Players").LocalPlayer
local team = script.Parent.Parent.SelectedTeam -- only reference the Instance here
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
script.Parent.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").LoadCharacter:FireServer(team.Value) -- use '.Value' here to get the up-to-date value stored.
-- if you define team as 'StringValue.Value' it was only store the value that's in place when the game starts
end)
Fox_2042
(real cat)
September 20, 2024, 2:46am
#18
It fixes the “nothing happens” problem, but the value still remains unchanged
i’ve had to sanity check myself twice and make sure I was in fact changing it lmaoa
Is it being changed from the properties window, or from another script?
sonic_848
(killer)
September 20, 2024, 2:49am
#20
Hear me out with this new way cause this seems to be causing you a lot of issues.
Set the selected team as an attribute under the player on the client of course (Accesibility)
When a player clicks use getattribute on the local player and send the selected team to the server.
You don’t have to add or change anything from your code and it’s simple too.
1 Like
Fox_2042
(real cat)
September 20, 2024, 3:03am
#21
I’ve never heard of these before… May you elaborate please?
sonic_848
(killer)
September 20, 2024, 3:05am
#22
like Player:SetAttribute("Team", "Team1")
to set the attribute and Player:GetAttribute("Team")
to get the value set. In this case that value would be “Team1”
1 Like
Fox_2042
(real cat)
September 20, 2024, 8:12pm
#23
same problem as before, whenever the attribute is passed to the server, it returns back to it’s original state
edit: i do like the idea of using attributes more though, very cool
sonic_848
(killer)
September 20, 2024, 8:16pm
#24
Are you setting the attribute from only one location?
Fox_2042
(real cat)
September 20, 2024, 8:21pm
#25
set here
local plr = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
plr:SetAttribute("Team", "Booking")
then passed to the server here
local plr = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").LoadCharacter:FireServer(plr)
end)
then the player gets teamed on the server here
game:GetService("ReplicatedStorage").LoadCharacter.OnServerEvent:Connect(function(plr)
print(plr:GetAttribute("Team"))
plr.Team = plr:GetAttribute("Team")
end)
sonic_848
(killer)
September 20, 2024, 8:31pm
#26
That’s because the attribute is set locally so the server cant see anything.
–Firing
script.Parent.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").LoadCharacter:FireServer(plr:GetAttribute("Team"))
end)
For the server use the code I gave you before for switching teams because it will now pass a string
Fox_2042
(real cat)
September 20, 2024, 8:45pm
#27
oh yea i forgot about that ;;
didn’t seem to change anything tho?
sonic_848
(killer)
September 20, 2024, 8:52pm
#28
Can you print the attribute on the client before you send it and when you receive it on the server?
Fox_2042
(real cat)
September 20, 2024, 8:57pm
#29
i already did that
top one is changing it, second one is sending and bottom one is recieving
NyrionDev
(Nyrion)
September 20, 2024, 9:01pm
#30
If the server changes the value it sees, it will replicate to the client. Therefore if you change the value on the client before that happens, the server will overwrite it with its version of the value.
sonic_848
(killer)
September 20, 2024, 9:04pm
#31
Sorry mb I forgot you sent a screenshot previously. Can you show the updated server code? Is it similar to what I was referencing? Because if the client prints the value showing it exists idk why the server wouldn’t be able to see it (Sorry in advance for the repetition)
1 Like
Fox_2042
(real cat)
September 20, 2024, 9:13pm
#32
here it is. idk either
game:GetService("ReplicatedStorage").LoadCharacter.OnServerEvent:Connect(function(plr)
plr.Team = plr:GetAttribute("Team")
end)
sonic_848
(killer)
September 20, 2024, 9:15pm
#33
I just said you cant get the attribute from the player
–Server
game:GetService("ReplicatedStorage").LoadCharacter.OnServerEvent:Connect(function(plr, Team)
plr.Team = game:GetService("Teams"):FindFirstChild(Team)
end)
–Client
script.Parent.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").LoadCharacter:FireServer(plr:GetAttribute("Team"))
end)
1 Like
Fox_2042
(real cat)
September 22, 2024, 6:34pm
#34
i dont even know exactly what i did, but it’s working now lol
astrovue
(astrovue)
September 22, 2024, 6:52pm
#35
Mark your post as the solution so this forum doesn’t stay live for eternity!
1 Like
system
(system)
Closed
October 6, 2024, 6:52pm
#36
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.