It does not seem to work, I tried to make it work but it still did not work. But all I need is a script that when I press a text button on a frame in starter gui it charges gold and gives the tool and stuff. Thank you!
But I did fix the money leader board as you said
tools can be accessed from the client, as long as it is in replicatedstorage (oopsie)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local cash = Instance.new("IntValue", leaderstats)
cash.Name = "Cash"
end
Next, put the tool in replicated storage. This will be accessed later.
This is a seperate script. Put this inside of ScreenGui.Shop.Tool
(local script btw)
local player = game.Players.LocalPlayer
local tool = player.PlayerGUI.Shop.Sword
local replicatedstorage = game:GetService("ReplicatedStorage")
tool.MouseButton1Click:Connect(function()
if player.leaderstats.Cash > Sword.Cash then
replicatedstorage:WaitForChild("Tools"):WaitForChild("Stone Axe").Parent = player.Character
end
end
I still canāt get it to work. If you need more info about what I did with things let me know. And by the way its a stone axe not a sword, and the info of the money leader board is on the first post. I can give a picture too.
the script at the bottom is where I need to do the cloning and gold charging.
Oops! I didnāt know you put the weapons inside of a folder. I edited the script. Also, would you mind showing me the script so that I can see what your issue is?
here is the script on the bottom of that picture. (I put some extra scripts in it from previous posts)
local player = game.Players.LocalPlayer
local tool = game.StarterGui.Buying.Frame.TextButton
local replicatedstorage = game:GetService(āReplicatedStorageā)
local Gold = player.leaderstats.Gold
local YourPrice = 100
tool.MouseButton1Click:Connect(function()
if Gold.Value > YourPrice then
Gold.Value -= YourPrice ā Subtract the price from your gold
local Tool = game.ReplicatedStorage.Tools[āStone Axeā]:Clone()
Tool.Parent = Player.Backpack
end
end
and here is the new money leader board script
function onPlayerEntered(player)
local stats = Instance.new(āFolderā)
stats.Name = āleaderstatsā
stats.Parent = player
local Gold= Instance.new("IntValue")
Gold.Name = "Gold"
Gold.Value = 0
Gold.Parent = stats
local Alexandrite= Instance.new("IntValue")
Alexandrite.Name = "Alexandrite"
Alexandrite.Value = 0
Alexandrite.Parent = stats
end
game.Players.ChildAdded:Connect(onPlayerEntered)
First of all, I need you to check if localplayer owns leaderstats.
local player = game.Players.LocalPlayer
if player:FindFirstChild("leaderstats") then
print("found leaderstats")
end
If this is found then this will make the job a lot easier to accomplish. Also, I believe you might need to dip your feet in remote events. Iāll reply to you once I finished it and the full explanation.
do I make that as a script and if yes where do I put it.
Put this in a script or something, put it after the leaderstats thing
game.Players.PlayerAdded:Connect(function(plr)
--[[
leaderstats code or something
--]]
local player = game.Players.LocalPlayer
if player:FindFirstChild("leaderstats") then
print("Test succeded")
end
end
I did this
function onPlayerEntered(player)
local stats = Instance.new(āFolderā)
stats.Name = āleaderstatsā
stats.Parent = player
game.Players.PlayerAdded:Connect(function(plr)
local player = game.Players.LocalPlayer
if player:FindFirstChild("leaderstats") then
print("Test succeded")
end
end)
local Gold= Instance.new("IntValue")
Gold.Name = "Gold"
Gold.Value = 0
Gold.Parent = stats
local Alexandrite= Instance.new("IntValue")
Alexandrite.Name = "Alexandrite"
Alexandrite.Value = 0
Alexandrite.Parent = stats
end
game.Players.ChildAdded:Connect(onPlayerEntered)
but I opened the output window and it did not print āTest succededā but the gold and alexandrite was on the leader board. Also what does this have to do with giving the player a tool.
EDIT: NVM
It means your going to have to use a different method for this, Iāll report to you in a bit.
now I think what I need to know is how to charge gold, clone tool and parent that tool to the players backpack. I know how to do that separately but when I try to put them together it does not work. The way I want to activate this script is buy clicking a text button on a screen gui. also should I put the tool in server storage, or replicated storage.
also this add on I put in the money leader board script should I keep it? its this:
game.Players.PlayerAdded:Connect(function(plr)
local player = game.Players.LocalPlayer
if player:FindFirstChild(āleaderstatsā) then
print(āTest succededā)
end
end)
Remote Events might do
local remotevent = game:GetService("ReplicatedStorage"):WaitForChild("Event")
local sword = game:GetService("ReplicatedStorage"):WaitForChild("Sword")
local SwordCost = 250
remoteevent.OnServerEvent:Connect(function(player)
if player.leaderstats.Cash > 250 then
local swordclone = sword:Clone()
swordclone.Parent == player.Backpack or player.Character
end
end
Sorry I didnāt get back to you eariler, I had a lot to do yesterday. Anyway, Here is the client script below
local player = game.Players.LocalPlayer
local cashgui = player.PlayerGui.Shop.SwordOption
local event = game:GetService("ReplicatedStorage"):WaitForChild("Event")
cashgui.MouseButton1Down:Connect(function()
event:FireServer()
end
end
Also, you need to put the sword inside of ReplicatedStorage
where do I put these scripts, and its a stone axe. also what is remote event
A remote event is communication from the server to client, or client to server. For example, if you want to press a key to be able to delete a part on the client, all you have to do is create a remote event.
Also, for the remote event script you put it inside of ServerScriptStorage, and then the client script belongs inside of the shop gui
If you want more info, here is a link
ok I put both scripts in the places you said, but swordclone.Parent is underlined. I also modified it a bit for the tools folder inside of replicated storage and then the axe. do I put a remote event in replicated storage.
Yes, you need to put the remote event in replicated storage.
ok I put one in. now what do I do. and also the scripts you sent I feel like they should be in opposite places. and are any of them local scripts.
Ehh, Iām currently not on roblox studio, but Iām sure you need to put the remote event on the OnServerEvent Event, but if it doesnāt work you can simply change the FireServer to FireClient. But, nevertheless I think iām right.
also, you will need to get into the game and click on the shop and buy the stone axe or something, you can change it with your needs.