Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI Shop buttons not placing gear in starterpack&backpack on click, any insight?

Asked by 5 years ago
Player=script.Parent.Parent.Parent.Parent.Parent
script.Parent.Text=tostring(script.Parent.ItemName.Value)..": "..tonumber(script.Parent.Cost.Value).." "..tostring(script.Parent.Currency.Value)
script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[script.Parent.Currency.Value].Value>=tonumber(script.Parent.Cost.Value) then
Player.leaderstats[script.Parent.Currency.Value].Value=Player.leaderstats[script.Parent.Currency.Value].Value-tonumber(script.Parent.Cost.Value)
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.Backpack
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.StarterGear
end
end
end)

Here's the code in each Item button, I know there aren't any typos with the number/string values and the gear is in lighting where it needs to be. Any ideas guys? Thanks in advance, I'll probably be headed to bed after this.

If you'd like to reach out to me through discord I'd be really grateful, I've got my details on my profile. (You're welcome to stop in just to chat, too.) Stuff in my workspace is set up like this, I don't think there are any problems here but just incase.

Sidenote : My close button also doesn't work, which also confuses me (I'm more concerned with the first issue though.)

print("Close button loaded")

button = script.Parent
window = script.Parent.Parent

function onClicked(GUI)
    window:remove()
end
script.Parent.MouseButton1Click:connect(onClicked)
0
That last example is a free model. User#24403 69 — 5y
0
Yeah, I used it since I don't really know what I'm doing. The whole project is something I followed from a youtube video. I just want things to work, man :( NFSPrime 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

so for the shop button its super easy

local item = game.Lighting.Item ---change lighting to the items parent and item to the items name
script.Parent.MouseButton1Click:Connect(function(plr)
local l = plr:WaitForChild("leaderstats") if l then
local c = l:FindFirstChild("Cash") if c then
if c.Value = 50 then --- change 50 to the items price
local itemclone = item:Clone()
itemclone.Parent = plr.Backpack
c.Value = c.Value - 50
end
end
end
end)

hope this helped :3

Ad

Answer this question