bIIocky
(blocky)
July 18, 2024, 2:33am
1
I’ve been trying to get this right for some time, but, whenever my current scripting setup gets called through the server, it spits out nil, despite having values to back it. I’m new to scripting, so this is probably a trivial oversight, but, I’ve been having difficulties with this.
Localscript code that sends information through from locascript to serverscript
localPlayer:GetPropertyChangedSignal("Team"):Connect(function()
for i, value in pairs(TeamArray) do
if localPlayer.TeamColor == TeamArray[1] then
iconEvent:FireServer(TeamArray[1], iconImageArray[1])
Server script simply to attempt to send data through, but returning nil apart from player
local function iconSwitch(player, TeamArray[1], iconImageArray[1])
print(TeamArray[1], iconImageArray[1])
end
I am unsure what you mean since your only sending the 1st element of the array, but
local function iconSwitch(player, TeamArray[1], iconImageArray[1])
has incorect syntax
instead it should be like
local function iconSwitch(player, team, iconImage)
print(team, iconImage)
end
bIIocky
(blocky)
July 18, 2024, 3:02am
3
Here are the arrays that are present
local iconImageArray = {
"rbxassetid://18413761813",
"rbxassetid://18413212927",
"rbxassetid://18413991987",
"rbxassetid://18414227286",
"rbxassetid://18414094164"}
local TeamArray = {
BrickColor.new("Royal purple"),
BrickColor.new("Bright red"),
BrickColor.new("Dark green"),
BrickColor.new("White"),
BrickColor.new("Electric blue"),
BrickColor.new("Black"),}
bIIocky
(blocky)
July 18, 2024, 3:03am
4
i had an idea where i don’t necessarily need to send array information, simply sending numbers should work for what i wish to achieve
If you wanted to, you could just send the entire array through the remote event
iconEvent:FireServer(TeamArray, iconImageArray)
and did you connect the iconSwitch function to the iconEvent.onClientEvent
bIIocky
(blocky)
July 18, 2024, 3:07am
6
yup, it has been connected
bIIocky
(blocky)
July 18, 2024, 3:09am
7
they return as nil when i tried to send the arrays
It isn’t connected to the correct event.
Instead, it should be connected to
iconEvent.OnClientEvent:Connect(iconSwitch)
bIIocky
(blocky)
July 18, 2024, 3:11am
9
I presume you meant OnServerEvent instead of OnClientEvent right?
Yeah you are right! i totally forgot about that. Does it work though with OnServerEvent?
bIIocky
(blocky)
July 18, 2024, 3:14am
12
for some reason, it sends a whole lot of times…
Are you changing the player’s team alot of times?
bIIocky
(blocky)
July 18, 2024, 3:16am
14
nope, only once. However, it might be an issue due to how I have formatted my serverscript.
bIIocky
(blocky)
July 18, 2024, 3:20am
15
it sends it 6 times for whatever the reason may be,…
Try put iconEvent:FireServer(TeamArray, iconImageArrray) outside of the for loop
1 Like
bIIocky
(blocky)
July 18, 2024, 3:21am
17
yup! it now only sends once. Thank you.
1 Like
system
(system)
Closed
August 1, 2024, 3:22am
18
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.