Hi everyone
I have a problem with the script, and it is that it cannot find a SurfaceGui in a Tool when I clone it. I don’t know what the problem could be.
Thanks for your attention.
Edit:I’ve already fixed the error, I just had to disable something in the streamingEnabled workspace and that’s it.
So thanks for everything and goodbye!
–Server Script
This code is when I have to remove the cards and then give them back. Then I try to find the SurfaceGui and it doesn’t find it.
function EquipCardTool()
for i,plr in pairs(game:GetService('Players'):GetPlayers()) do
if plr.Character:FindFirstChild('Cards') then
plr.Character:FindFirstChild('Cards'):Destroy()
end
end
wait(0.5)
for i,plr in pairs(game:GetService('Players'):GetPlayers()) do
if plr ~= nil then
local deckofcards= game.ReplicatedStorage.Cards:Clone()
deckofcards.Parent = plr.Character
end
end
end
weird, does the surfacegui not just visually appear or doesnt it get cloned at all? try printing out the Instance of the tool when it is given to the player, then click on it and check if the surfacegui is there or not
The code is written in the script server so it shouldn’t give an error right? Everything is cloned fine but I always get an error after cloning and trying to search for SurfaceGui.
Hello! I tried simulating your problem and it doesn’t seem to be anything unnatural.
Maybe you need to rename the tool’s part that the player should hold to Handle? Tools can fall into the void and get destroyed if they’re not probably welded.
If this doesn’t work, a screenshot of the full hierarchy of the Cards tool (like the one you gave earlier) may give more insight to your problem.
Edit: Here's the code i used if you want to take a look.
local tool = game:GetService("ReplicatedStorage").Tool
local clone = tool:Clone()
print(clone:GetChildren())
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Wait()
clone.Parent = plr.Backpack
print(clone:GetChildren())
end)
Hi, I tried what you told me and it’s still the same.
Well, I think I know why I have the error, that’s because I think the information from the remote event that I sent from the client to the server is not arriving and I think it sends a null value, that’s why I get that error.
Edit: I have a question, why doesn’t all the information from the remote event that I send from the client arrive to the server?
You may be using incorrect parameters in your code (e.g the necessary player parameter), otherwise I can’t really help you with the current information.