Hi, so i’m making a piggy like game using alvin blox’s kit. I’ve ran into an issue though with a simple fix that I am struggling with. Basically, I want the first character to be named ducky for my game but that messes up the game for some reason so it has to be named piggy making it named that in the shop. So I assumed I could do a script like this to replace the name?
while true do
game:GetService(‘Players’).LocalPlayer:WaitForChild(‘PlayerGui’)
if PlayerGui.MainGUI.Shop.ClientShop.Template.Title.Text == “Piggy”
then PlayerGui.MainGUI.Shop.ClientShop.Template.Title.Text = “Ducky”
end
end
It’s probably connected to another name somewhere else in the game, also you should throw a wait() inside of the while true do, if it isn’t crashing your studio I’m very surprised.
Edit: where is your script located, and what type of script
I’m not sure what it’s meant to do, but you need to use a LocalScript for the client (including UI).
If you’re trying to change ‘Piggy’ to ‘Ducky’, don’t worry about the scripting aspect of it (assuming you just want to change the default character, I’m kind of confused at this point). You can change the text of a TextLabel/TextButton, etc here:
If you’re following a tutorial series, make sure to just make it exactly how the video does it, then if you want to, tamper with things later on once you’ve finished creating it exactly how it was meant to be done. Make sure you’re not just trying to freestyle your way through it with limited knowledge of coding.
I actually got the source code from him, and haven’t changed anything. The only thing i’m trying to change is the name of the piggy, which isn’t possible as i’ve watched them all.
Assuming you’re trying to replace all occurrences of something, you could do this through the command line. Your script is going to run every time the server starts, and if I’m interpreting it correctly, you just want ‘Piggy’ changed.
for _, descendant in pairs(path.to.GUIs:GetDescendants()) do if descendant:IsA("TextButton") or descendant:IsA("TextLabel") then if descendant.Text == "Piggy" then descendant.Text == "Ducky" end end end
You’ll need to change path.to.GUIs to wherever your UI is located. For example, if they were located in StarterGui:
for _, descendant in pairs(game:GetService("StarterGui"):GetDescendants()) do if descendant:IsA("TextButton") or descendant:IsA("TextLabel") then if descendant.Text == "Piggy" then descendant.Text == "Ducky" end end end
If that’s the only path you want to use, use this:
for _, descendant in pairs(game:GetService("StarterGui").MainGui:GetDescendants()) do if descendant:IsA("TextButton") or descendant:IsA("TextLabel") then if descendant.Text == "Piggy" then descendant.Text == "Ducky" end end end
This will work for its intended function, but this seems like an exercise in futility
I would imagine there are many other scripts within this template that relies upon the fact that objects are named ‘Piggy’.
@ItzGpYt I would highly recommend that you:
Follow whatever tutorial this is from start to finish so you understand what you’re changing and how to do it
Read through each script in its entirety, and look to see if it references/searches for any GameObjects named ‘Piggy’ - you would need to change each of these instances, as well as altering the script(s) to look for ‘Ducky’
I just fixed this by naming the character ducky, then having a timer for 30 seconds then changes it to piggy so the game loads but in the store it says ducky.