I’m having trouble getting attributes using :GetAttribute().
Basically, the localscript gets the configuration instance (which is correct, I have checked to see if it was an instance) in ReplicatedStorage, and sends it off to the serverscript where attributes are added and returned. This is then passed on to the InsideParty() function.
InsideParty() tries to grab the “Owner” attribute from the configuration, but the error ‘attempt to call missing method 'GetAttribute' of string
’ is raised.
The confusing part about this is that it sends through an instance and comes back with a string. Why does it do this?
Here are the scripts:
PlayerScript (local), displayParties() function:
function displayParties()
if gui.MatchmakingFrame.Visible == true then
if #rs.MultiplayerMatches:GetChildren() > 0 then
for _, box in pairs(gui.MatchmakingFrame.ScrollingFrame:GetChildren()) do
if box:IsA("Frame") and box.Visible == true then
box:Destroy()
end
end
for _, match in pairs(rs.MultiplayerMatches:GetChildren()) do
local box = gui.MatchmakingFrame.ScrollingFrame.Default:Clone()
box.Name = match.Name
box.PartyName.Text = match:GetAttribute("PartyName")
box.Members.Text = match:GetAttribute("Members").."/"..match:GetAttribute("MaxMembers")
box.Type.Text = match:GetAttribute("Type")
box.Owner.Text = match:GetAttribute("Owner")
match:GetAttributeChangedSignal("Members"):Connect(function()
box.Members.Text = match:GetAttribute("Members").."/"..match:GetAttribute("MaxMembers")
end)
match:GetPropertyChangedSignal("Parent"):Connect(function()
if not match.Parent then
box:Destroy()
end
end)
box.Join.MouseButton1Click:Connect(function()
if match:GetAttribute("Members") < match:GetAttribute("MaxMembers") then
if match:GetAttribute("Status") ~= "Starting" then
local result = remoteFunction:InvokeServer("JoinMatch", match)
if result then
InsideParty(result)
end
else
Msg("This match has already started.", 4, Color3.new(0.9, 0, 0))
end
else
Msg("This party is full.", 3, Color3.new(0.75, 0, 0))
end
end)
box.Parent = gui.MatchmakingFrame.ScrollingFrame
box.Visible = true
end
end
end
end
ServerScript, responding to the remote function:
elseif action == "JoinMatch" then
local hasBall = false
for i = 1, 5 do
if game.ServerStorage.Spheres:FindFirstChild(player:GetAttribute("Sphere"..i)) then
hasBall = true
break
end
end
if hasBall == false then player:Kick("") end
local match = val
if not match then return false end
if match:GetAttribute("Members") >= match:GetAttribute("MaxMembers") then
return "Full"
elseif match:GetAttribute("Status") == "Starting" then
return "Started"
else
for _, party in pairs(rs.MultiplayerMatches:GetChildren()) do
if party:FindFirstChild(player.Name) then
return "InMatch"
end
end
match:SetAttribute("Members", #match:GetChildren())
local p = Instance.new("Folder", match)
p.Name = player.Name
p:SetAttribute("Order", #match:GetChildren())
local done = nil
local image = nil
repeat
local success, error = pcall(function()
local img, success, loaded = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size352x352)
if success and loaded then
image = img
return
end
end)
until done and image
p:SetAttribute("Image", image)
return match
end
I will note that it is almost 12am as I am writing this, so I will not respond for a while.