It’s not due to loading times since the Remote Event is fired after the Player clicks an NPC, so everything would definately be loaded at that point.
I also assumed that the cloned parts are just being deleted but I can still see them on the client. Since this is a local script, I don’t believe that the server needs to see it, not that it needs to.
Can you try leaving the argument field for the function in the script firing the event empty, like this:
script.Parent.ClickDetector.MouseClick:Connect(function()
local RE = Firedplr.PlayerGui.NPCTextGui.InitiateConversation
RE:FireClient("CoreGiver", PlrtoCopy)
end)
On the server side you are sending only two arguments whereas on the client side you are trying to get three arguments, and so one of those arguments is shown as nil
And as for npcdummy being nil, can you do a print statement for each action performed like this
local plr = game.Players.LocalPlayer
local RE = script.Parent.InitiateConversation
print("LocalPlayer:", plr.Name)
local PlrDummy = game.Workspace.PlrDummy:Clone()
PlrDummy.Parent = plr.PlayerGui.NPCTextGui.PlayerViewport
print("PlrDummy cloned and parent set to PlayerViewport")
local NPCDummy = game.Workspace.NPCDummy:Clone()
NPCDummy.Parent = plr.PlayerGui.NPCTextGui.NPCViewport
print("NPCDummy cloned and parent set to NPCViewport")
RE.OnClientEvent:Connect(function(NPC, NPCAppearance, AltAppearance)
print("Received OnClientEvent")
print("NPC:", NPC.Name)
print("NPCAppearance:", NPCAppearance)
print("AltAppearance:", AltAppearance)
NPCDummy.Humanoid:ApplyDescription(NPCAppearance)
print("Applied NPCAppearance to NPCDummy")
local plrDescription = game.Players:GetHumanoidDescriptionFromUserId(plr.UserId)
print("Player description obtained:", plrDescription)
PlrDummy.Humanoid:ApplyDescription(plrDescription)
print("Applied player description to PlrDummy")
-- Initiate Dialogue
end)
I see, I completely forgot that AltAppearance was there since it was part of fixing an older issue I resolved so I forgot to delete it
After adding the print statements, I’ve discovered that the event does fire but NPC and NPCAppearance are printed as nil which is interesting.
NPC is just a string that was set whilst being fired and NPCAppearance is from PlrtoCopy = PS:GetHumanoidDescriptionFromUserId(36429180) which isn’t nothing since its used to apply the description on an NPC and has done so without issue
I’m going to assume that the NPCAppearance didn’t get sent because it’s an instance which apparently cant be sent down to clients, but why is the string nil?
local PS = game:GetService("Players")
local PlrtoCopy = PS:GetHumanoidDescriptionFromUserId(36429180)
local hum = script.Parent.Humanoid
hum:ApplyDescription(PlrtoCopy)
print("Humanoid description applied to NPC.")
script.Parent.ClickDetector.MouseClick:Connect(function()
print("Mouse clicked on NPC.")
local RE = game.ReplicatedStorage.RemoteEvents.InitiateConversation
RE:FireClient("CoreGiver", PlrtoCopy)
print("InitiateConversation event fired with player description.")
end)
Try this and also print your string
Add player argument in the click detector function too, you cant fire a remote event to a string
I added back the player argument, I don’t know why the previous user wanted to see it removed so i just added it back
This caused the String to return as Nil since you can’t do String.Name.
I was correct in my assumption, changing the Description to print the ID instead of the instance itself no longer had it return to nil
(ignore the extra comments in my code I was actually about to make another post for an issue i’m having with viewports and models not showing up in them.)