So I am making a shop for my game where you can buy and equip skins, the issue is whenever I want to buy a skin, it doesn’t work. There isn’t any error in output and I think it may be a nil string but I didn’t make it nil? Any help would be appreciated!
Local script:
local player = game.Players.LocalPlayer
local coins = player:WaitForChild('Coins')
local buySound = script.Parent.Parent.Parent:WaitForChild('BuySound')
local click = script.Parent.Parent.Parent:WaitForChild('Click')
local events = game.ReplicatedStorage:WaitForChild('RemoteEvents')
script.Parent:WaitForChild('Button').MouseButton1Click:Connect(function()
if coins.Value >= script.Parent.Price.Value and script.Parent.Owned.Value == false then
events.BuyEvent:FireServer(player, 'SkinTest')
elseif script.Parent.Owned.Value == true then
events.EquipEvent:FireServer(player, 'SkinTest')
script.Parent.Button.Text = 'Equipped'
end
end)
events:WaitForChild('BuyEvent').OnClientEvent:Connect(function(name, successOrNo)
if successOrNo == true and name == script.Parent.Name then
buySound:Play()
script.Parent.Button.Text = 'Equip'
script.Parent.Status.TextColor3 = Color3.new(1, 1, 1)
script.Parent.Status.Text = 'Owned'
end
end)
Server script:
events.BuyEvent.OnServerEvent:Connect(function(player, name)
local item = game.ServerStorage.SkinsCost:FindFirstChild(name)
if item then
if player:FindFirstChild('Coins').Value >= item.Value then
player:FindFirstChild('Skins'):FindFirstChild(item.Name).Value = true
events.BuyEvent:FireClient(player, name, true)
end
end
end)
events.EquipEvent.OnServerEvent:Connect(function(player, name)
local item = player.Skins:FindFirstChild(name)
if item.Value == true then
player.EquippedSkin.Value = item.Name
end
end)