Roblox Studio: Shop System - roblox

Hello,
I have a shop system that half works. It has one problem. When you buy something from the shop, your money goes down, as it's suppose to. But then if you get more money, the number of your money springs back up to what it was, plus it gives you the new money that you got. I don't know how to fix it. This is the code.
local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
if player.leaderstats:FindFirstChild("Money").Value >= price.Value then
player.leaderstats:FindFirstChild("Money").Value = player.leaderstats:FindFirstChild("Money").Value - price.Value
game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
end
end)
This is the code that puts the item in the inventory:
local tools = game.ReplicatedStorage:WaitForChild("Tools")
game.ReplicatedStorage.ShopBuy.OnServerEvent:Connect(function(player,tool)
local clone = tools:FindFirstChild(tool):Clone()
clone.Parent = player.Backpack
local clone2 = tools:FindFirstChild(tool):Clone()
clone2.Parent = player.StarterGear
end)

Changes made in LocalScripts aren't replicated to everyone. Which means that the changes only appear for you. If you want to update your leaderstats, make the change in a Script.
To fix your problem, move the price check into the Script that is handling the ShopBuy RemoteEvent.
local item = script.Parent.Parent
local shopBuy = game.ReplicatedStorage.ShopBuy
script.Parent.MouseButton1Click:connect(function()
shopBuy:FireServer(item)
end)
Then parse the details in your server Script.
local tools = game.ReplicatedStorage.Tools
local shopBuy = game.ReplicatedStorage.ShopBuy
shopBuy.OnServerEvent:Connect(function(player, item)
-- get some details about the tool
local toolName = item.ItemName.Value
local price = item.Price.Value
local money = player.leaderstats:FindFirstChild("Money")
-- check that the player has enough money
if money.Value >= price then
money.Value = money.Value - price
-- give the tool
local clone = tools:FindFirstChild(toolName):Clone()
clone.Parent = player.Backpack
local clone2 = tools:FindFirstChild(toolName):Clone()
clone2.Parent = player.StarterGear
end
end)

Related

Roblox-How to fix tool manager

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local remotes = ReplicatedStorage:FindFirstChild("Remotes")
local tools = ServerStorage:FindFirstChild("Tools")
local scripts = ServerStorage:FindFirstChild("Scripts")
local toolConfig = require(ReplicatedStorage:FindFirstChild("Config"):FindFirstChild("ToolConfig"))
remotes.ToolActivated.OnServerEvent:Connect(function(player: Player)
local playerTool = player.inventory.EquippedTool.Value
for tool, toolTable in pairs(toolConfig) do
if tool == playerTool then
player.leaderstats.Decibel.Value += toolTable.Decibel
end
end
print(player.Name)
end)
for _, tool in ipairs(tools:GetChildren()) do
local script = scripts.Click:Clone()
script.Parent = tool
end
This is my code to make the Decibel Value from leaderstats go up
Then It doesn't show any error up but it isn't working.
It doesn't print the player name and also it doesn't make the Decibel Value go up
help
On the client, you need to fire the signal.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remotes = ReplicatedStorage:FindFirstChild("Remotes")
local tool = script.Parent
tool.Activated:Connect(function()
remotes.ToolActivated:Fire()
end

How to set initial player health to a custom value in Roblox Studio?

My goal is to have an initial/max custom player health for my Roblox place in Roblox Studio.
To do this I have created a script in StarterPlayer/StarterPlayerScript with the following content:
local DEFAULT_HEALTH = 10
game.Players.PlayerAdded:connect(function(player)
player.character.Humanoid.MaxHealth = DEFAULT_HEALTH
player.character.Humanoid.Health = DEFAULT_HEALTH
end)
I have also tried with:
local DEFAULT_HEALTH = 10
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.MaxHealth = DEFAULT_HEALTH
Humanoid.Health = DEFAULT_HEALTH
in both cases when I playtest it (TEST->PLAY) it seems the default health=100 is used instead of health=10
Is it possible to fix the issue outlined?
The PlayerAdded event fires as soon as the player joins the server, but their character model doesn't load into the world immediately. So you need to wait for the player's character model to spawb. Luckily, you can use the CharacterAdded event to know when that happens.
So using a Script in the Workspace or ServerScriptService, try this :
local DEFAULT_HEALTH = 10
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.MaxHealth = DEFAULT_HEALTH
character.Humanoid.Health = DEFAULT_HEALTH
end)
end)

Odoo 12 : Not enought limit time to finish the backup?

I use the auto_backup to backup production database everyday.
It was working well until now.
Now, the backup can't finish until the end, I mean, I get the half size of the .zip file and it is impossible to restore it.
Normaly, the backup takes about 15mn.
I think that it's related to the Odoo configuration.
Here it is :
workers = 3
longpolling_port = 8072
limit_memory_soft = 2013265920
limit_memory_hard = 2415919104
limit_request = 8192
limit_time_cpu = 600
limit_time_real = 3600
limit_time_real_cron = 3600
proxy_mode = True
Can you help me?
I have another question, What does mean limit_time_real_cron = -1 if the limit_time_real_cron = 0 is unlimited?
Try to increase limit_time_cpu.

Group team change scripts that work currently?

Any working roblox team change GUIs that you have to be in a certain group to change teams in?
Hi there, I've spent 20 minutes to code a team-changing GUI for you, follow my steps below for it to work. (This is FilteringEnabled friendly)
Step 1 Insert a LocalScript into StarterGui
Step 2 Copy the stuff from LocalScript below and paste it into your LocalScript
Step 3 Insert a Script into either Workspace or ServerScriptService (your choice)
Step 4 Copy the stuff from ServerScript below and paste it into your script
ServerScript
local teams = game:GetService("Teams")
local settings = {
["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
["TitleText"] = "Team Changer", --title text in the gui
["TitleFont"] = "ArialBold", --font of title
}
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
local plr = game.Players.LocalPlayer
local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
local frame = Instance.new("Frame",teamGUI)
frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
local title = Instance.new("TextLabel",frame)
title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
local closebutton = Instance.new("TextButton",title)
closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
local list = Instance.new("ScrollingFrame",frame)
list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
local UILayout = Instance.new("UIListLayout",list)
local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
for i,v in pairs(getTeams) do
print("[Team " .. i .. " found]: " .. v:GetFullName())
local teamButton = Instance.new("TextButton",list)
teamButton.BackgroundColor3 = v.TeamColor.Color
teamButton.Size = UDim2.new(1,0,0,40)
teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
teamButton.MouseButton1Down:connect(function()
print("You changed teams. You are now in: " .. v.Name)
serverTeamHandler:InvokeServer(v)
end)
end
closebutton.MouseButton1Click:connect(function()
frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
local returnButton = Instance.new("TextButton",teamGUI)
returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
returnButton.MouseButton1Down:connect(function()
returnButton:Destroy()
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
end)
end)
LocalScript
local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
teamChanger.Name = "teamChanger"
local function changeTeam(client,team)
print(client.Name .. "changed teams: now in" .. team.Name)
client.Team = team
end
teamChanger.OnServerInvoke = changeTeam
If you followed these steps correctly, you should now have a working team changing GUI in your game! It works as long as you have already inserted Teams in your game. The first few lines in the LocalScript can also be customized as well!

How do I make a working team changer GUI in roblox?

In 2018 Roblox switched coding platforms I believe, most scripts have survived, however I have failed to find a working team changer for myself this year that changes your team when clicked depending if you are in certian groups or not. My scripter says that it works in studio, but an error pops up in game that says "
TeamColor is not a valid member of PlayerGui
Stack Begin
Script 'Players.Benyal.PlayerGui.Starter GUI.TeamGui.Frame.Research and Development.LocalScript', Line 8
Stack End"
My scipter tried many different ways but it just wont work! Any seggustions?
This solution uses two scripts (one LocalScript and one Script), follow the steps below to make a team changing GUI!
local teams = game:GetService("Teams")
local settings = {
["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
["TitleText"] = "Team Changer", --title text in the gui
["TitleFont"] = "ArialBold", --font of title
}
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
local plr = game.Players.LocalPlayer
local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
local frame = Instance.new("Frame",teamGUI)
frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
local title = Instance.new("TextLabel",frame)
title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
local closebutton = Instance.new("TextButton",title)
closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
local list = Instance.new("ScrollingFrame",frame)
list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
local UILayout = Instance.new("UIListLayout",list)
local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
for i,v in pairs(getTeams) do
print("[Team " .. i .. " found]: " .. v:GetFullName())
local teamButton = Instance.new("TextButton",list)
teamButton.BackgroundColor3 = v.TeamColor.Color
teamButton.Size = UDim2.new(1,0,0,40)
teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
teamButton.MouseButton1Down:connect(function()
print("You changed teams. You are now in: " .. v.Name)
serverTeamHandler:InvokeServer(v)
end)
end
closebutton.MouseButton1Click:connect(function()
frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
local returnButton = Instance.new("TextButton",teamGUI)
returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
returnButton.MouseButton1Down:connect(function()
returnButton:Destroy()
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
end)
end)
Step 1 Insert a LocalScript into StarterGui
Step 2 Copy the stuff above and paste it into this LocalScript
Step 3 Insert a Script into either Workspace or ServerScriptService (your choice)
Step 4 Copy the stuff below and paste it into the Script
local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
teamChanger.Name = "teamChanger"
local function changeTeam(client,team)
print(client.Name .. "changed teams: now in" .. team.Name)
client.Team = team
end
teamChanger.OnServerInvoke = changeTeam
If you followed these steps correctly, you should now have a working team changing GUI in your game! It works as long as you have already inserted Teams in your game. The first few lines in the LocalScript can also be customized as well!