#RemoteEvent changes parameter to 'Nil'

13 messages · Page 1 of 1 (latest)

steady seal
#
local player = game.Players.LocalPlayer
local petsFolder = player:WaitForChild("PetsInventory")
local equipped = petsFolder:WaitForChild("Equipped")
local cloneSender = game:GetService("ReplicatedStorage"):WaitForChild("PetCloneSender")

player.CharacterAdded:Wait()


local pet = equipped:FindFirstChildWhichIsA("Part")
    local animScript = pet:FindFirstChildWhichIsA("Script")
    local petModifier = pet:FindFirstChild("ScoreModifier")
    cloneSender:FireServer(pet.Position, pet.Color, pet.Name, pet.Size, pet.CFrame, pet.CanCollide, pet.CanTouch, pet.Anchored, petModifier.Value)

After this script fires the server, every parameter retains its correct value except for 'petModifier,' which is inexplicably changed to nil. Why might this be?

unkempt marsh
steady seal
#

Sorry, I forgot to edit this message but I tried that already. I've tried changing the parameter to 'petModifier.Value' and changing the original variable to 'pet:FindFirstChild("ScoreModifier").Value' and the parameter becomes nil regardless

unkempt marsh
steady seal
#

Int

unkempt marsh
#

Ok. Can you send the script on the server? (Just the function that receive the Event)

steady seal
#
function clonePet(player, vPosition, vColor, vName, vSize, vCFrame, vCanCollide, vCanTouch, vAnchored, animSource, petModifierValue)
    
    local scoreModifier = Instance.new("IntValue")
    scoreModifier.Value = petModifierValue
    print(petModifierValue)
    print(scoreModifier.Value)
    
end

cloneSender.OnServerEvent:Connect(clonePet)

Here petModifierValue = nil, and scoreModifier.Value = 0.

unkempt marsh
#

Are you sure ScoreModifier exists on the client, in the moment of firing the Event? Because FindFirstChild() doesn't throw error if it's not found, it just move on returning nil.

steady seal
#

Pretty sure. If I add a print function in the LocalScript for ScoreModifier.Value it prints the correct value

#

Thanks for the help, this is probably going to turn out to be something really obvious that I'm just missing

#

I figured it out

#

I had an extra parameter in the ServerScript that I had added previously with plans to do something with, so I just had one extra parameter that was doing nothing

#

oh my god