Start with this! I can make a GUI button that when clicked, and you have 10 money, will give you a pet! Just follow these steps!
1
Make a RemoteEvent in ReplicatedStorage called Pets.
Move the pet to ServerStorage and call it "Pet1"
2
Put this script inside the pet and disable it:
while true do
wait(0.1)
script.Parent.Position = script.Parent.Parent.Position - Vector3.new(3,3,0)
end
2
Put this LocalScript inside a GUI button
script.Parent.MouseButton1Click:Connect(function()
local Player = game.Players.LocalPlayer
if Player.leaderstats:FindFirstChild("Money").Value >= 10 then
game.ReplicatedStorage:FindFirstChild("Pets"):FireServer(Player.Name,"Pet1")
end
end)
3
Put this Script in ServerScriptService
game.ReplicatedStorage:FindFirstChild("Pets").OnServerEvent:Connect(function(player,pet)
local Pets = game.ServerStorage:FindFirstChild(pet)
if Pets then
local Clone = Pets:Clone()
Clone.Parent = game.Workspace:FindFirstChild(player):FindFirstChild("HumanoidRootPart")
Clone:FindFirstChild("Script").Disabled = false
end
end)
Even if this does not work, it should give you some ideas! If you have any questions, comment below!
Best,
TheLastHabanero
EDIT
To save pets, you need to make a table:
local DS = game:GetService("DatastoreService")
local Store = DS:GetDataStore("Pets")
game.Players.PlayerAdded:Connect(function(plr)
local Stats
local success,fail = pcall funtion()
Stats = Store:GetAsync(plr.UserId.."-Pets")
end
if success then
for i, stat in pairs(Stats) do
local Clone = game.ServerStorage:FindFirstChild(stat)
if Clone then
Clone:Clone().Parent = plr.Character:FindFirstChild("HumanoidRootPart")
end
end
else
end
end
game.Players.PlayerRemoving:Connect(function(plr)
local Pets = {}
local Childs = plr.Character:FindFirstChild("HumanoidRootPart"):GetChildren()
if #Childs >= 1 then
for i,child in pairs(Childs) do
table.insert(child)
end
end
pcall function()
Store:SetAsync(plr.UserId.."-Pets",Pets)
end
end
Just make sure to make all the pets in Lighting and it should work!
Unfortunately, unequipping and equipping will require some time to make, so you will have to wait. I'm sorry. But hey! Here's the save part! Have fun!
TheLastHabanero
11 comments
Thanks! I will try out it out today.
Nice answer layout by the way.
I hate to be "requesting stuff" but how would I make them be able to unequip/equip owned pets and how to make their owned pets save?
Thank you :D
Um... You didn't answer my question.
Ohh. Ok. Ask the question as a different question on scriptinghelpers
Thank you!
Oh wait nvm Ill just edit
Thanks! I will try the new version later on today.
Wait so do I put the pets in Lighting or ServerStorage?
ServerStorage