-
What do I want to achieve? So i want to update the text of a status label or tween a frame whenever a player clicks a button
-
What is the issue? It is not updating the text even though no errors
-
What solutions have I tried so far? Looked at yt vids, other forum posts and devhub but still cant find a solution
-- module script
local items = game.ReplicatedStorage.Shared:WaitForChild("Tools")
print("ok")
function remotecon.buy(player,toolName)
print("workinh?")
local tool = items:FindFirstChild(toolName)
print("A")
if tool ~= nil then
print("Aa")
if not player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value ~= toolName then
local price = tool.Cost.Value
print("aaaa")
--plr dosent have tool
if player.leaderstats.Coins.Value >= price then
print("sugoma")
local newtoolval = Instance.new("StringValue")
print("THIS IS SPONSERED")
newtoolval.Name = toolName
print("Ajh")
newtoolval.Parent = player
print("Ajjk")
player.Equipped.Value = toolName
print("Ad")
for i,v in pairs(player.Backpack:GetChildren()) do
print("A")
if v:IsA("Tool") then
print("Avf")
v:Destroy()
print("Aplx")
end
print("pid")
end
print("stu")
local gear = tool:Clone()
print("z")
gear.Parent = player.Backpack
local gear2 = tool:Clone()
gear2.Parent = player.Ownedtools
print("y")
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price
print("x")
return "Yes"
else
return "no"
end
elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value ~= toolName then
print("h")
for i,v in pairs(player.Backpack:GetChildren()) do
print("A")
if v:IsA("Tool") then
v:Destroy()
print("m")
end
end
local gear = tool:Clone()
print("f")
gear.Parent = player.Backpack
print("c")
return "Equipped"
elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value == toolName then
print("b")
for i,v in pairs(player.Backpack:GetChildren()) do
print("raid")
if v:IsA("Tool") then
v:Destroy()
print("shadow")
end
end
local gear = tool:Clone()
print("legends")
gear.Parent = player.Backpack
return "Equipped"
end
else
return "error"
end
end
--Server script
local remotecon = require(script.Parent.remotescript)
local buytool = game.ReplicatedStorage.Remotes.buytool
buytool.OnServerInvoke = function(player, toolName)
remotecon.buy(player,toolName)
end
--Client script
local RS = game:GetService("ReplicatedStorage")
local Shared = RS:WaitForChild("Shared")
local ToolFolder = Shared:WaitForChild("Tools")
local Tools = ToolFolder:GetChildren()
local parent = script.Parent
local selectedtemp = nil
local toolsGui = parent:WaitForChild("tools_gui")
local toolsFrame = toolsGui:WaitForChild("tools_frame")
local scrollingFrame = toolsFrame:WaitForChild("ScrollingFrame")
local temp = scrollingFrame:WaitForChild("temp")
local shop = script.Parent.tools_gui.tools_frame
local buy = shop:WaitForChild("canbuy")
local framess = toolsGui:WaitForChild("Frame")
local status = shop:WaitForChild("status")
for i, item in ipairs(Tools) do
if item:IsA("Tool") then
local price = item:FindFirstChild("Cost")
local img = item:FindFirstChild("ImgID")
local order = item:FindFirstChild("order")
if price and img and order then
print(item.Name)
local temp = temp:Clone()
temp.Parent = scrollingFrame
temp.Name = item.Name
temp.img.Image = img.Value
local priceval = Instance.new("StringValue")
priceval.Value = price.Value
priceval.Parent = temp
temp.Visible = true
temp.MouseButton1Click:Connect(function()
shop["tool_img"].Image = img.Value
selectedtemp = temp
shop.price.Text = price.Value
shop.name.Text = item.Name
end)
else
continue
end
end
end
if selectedtemp ~= nil then
end
shop.canbuy.MouseButton1Click:Connect(function()
print(selectedtemp)
if selectedtemp ~= nil then
local result = game.ReplicatedStorage.Remotes.buytool:InvokeServer(selectedtemp.Name)
print(result)
if result == "Equipped" then
status.Text = "Equipped"
elseif result == "Yes" then
status.Text = "Equipped"
elseif result == "No" then
status.Text = "Buy"
framess:TweenSize(UDim2.new(0.279, 0,0.1, 0) ,
"Out" ,
"Elastic" ,
1
)
end
print("Working")
end
end)