I'm just trying to make a simple script, or so I thought it should have been, and this script tries to access the
plr.Team
value, with "plr" being
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
Now, I've had a really massive issue with my script(s), as the client and the server seem to see the player as being on different teams. What I mean by this is that: I have two teams (Team1 and Team2) When I call a function to get the player's team on the server it always returns with "Team1", even if the Roblox leaderboard shows the player to be on Team2 However, if I call this code from the client side, It returns with the correct value.
I'm wondering why this is, and how I can fix it, as this would cause major issues for me. I've tried many things, such as trying to set the teams myself, but I've had no luck so far. If anyone knows anything about this, I would be very appreciative as this is really bugging me (excuse the pun).
I will provide my scripts here. These scripts are the children of the part that the player shall touch.
Script: isTouching
debounce = false script.Parent.ControllingTeam.Value = nil rechargeTime = 0.5 script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if debounce == false and hit.Parent:FindFirstChild("Humanoid").Health ~= 0 and plr.Team ~= script.Parent.ControllingTeam.Value then debounce = true script.Parent.ControllingTeam.Value = plr.Team end end wait(rechargeTime) debounce = false end)
Also, I am quite aware this code is messy, I've just been experimenting with trying to fix the bug.
Script: ptsGiver
local delayTime = 5 --this is how long the script should wait before giving the team of the touching player extra points local team = script.Parent.ControllingTeam while true do if team.Value ~= nil then team.Value.Points.Value += 5 print(team.Value) print(team.Value.Points.Value) end wait(delayTime) end
Also, another thing that may be of use that I thought I should probably point out is that when I try to manually set the player's team value to Team2, it just doesn't let me and it comes up with Team1, no matter what I do.
If you need me to provide extra detail, let me know, and as i said beforehand, any help would be greatly appreciated. Thank you.