I’m trying to make a shop sell system, but transfering the money to the leaderstats isn’t working.
the value “Money” isn’t actually the number but the player for some reason.
Client script:
script.Parent.InputBegan:Connect(function(obj)
if obj.UserInputType == Enum.UserInputType.MouseButton1 then
local target = game.Players.LocalPlayer.Inventory:FindFirstChild(script.Parent.Title.Text)
game.ReplicatedStorage.AddMoney:FireServer(game.Players.LocalPlayer,tonumber(target))
target:Destroy()
script.Parent:Destroy()
end
end)
Server script: (only important part)
game.ReplicatedStorage.AddMoney.OnServerEvent:Connect(function(plr,money)
plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + money
local ui = Instance.new("ScreenGui")
ui.Parent = plr.PlayerGui
local text = Instance.new("TextLabel")
text.TextColor3 = Color3.fromRGB(170, 170, 170)
text.TextScaled = true
text.Font = Enum.Font.FredokaOne
text.BackgroundTransparency = 1
text.Position = UDim2.new(math.random(1,10)/10,0,1,0)
text.Parent = ui
text.Text = "+"..money
text.Size = UDim2.new(0, 200,0, 50)
local tweenp = game:GetService("TweenService"):Create(text,TweenInfo.new(2,Enum.EasingStyle.Sine),{Position = UDim2.new(text.Position.X,0,0.5,0)})
local tweent = game:GetService("TweenService"):Create(text,TweenInfo.new(2,Enum.EasingStyle.Linear),{TextTransparency = 1})
tweenp:Play()
tweent:Play()
game:GetService("Debris"):AddItem(ui,2)
end)