when i run the game the error in the title appear
local player = game.Players.GetPlayerFromCharacter local leaderstats = player:WaitForChild("leaderstats") local config = script.Parent.Parent.Parent.Frame.ScrollingFrame.Frame.ImageButton.Config script.Parent.MouseButton1Click:Connect(function() if leaderstats.Diamonds.Value >= config.Cost.Value then leaderstats.Diamonds.Value = leaderstats.Diamonds.Value - config.Cost.Value end end)
getplayerfromcaharcter is a function, you'd have to call it:
local player = game.Players:GetPlayerFromCharacter( the player you have ) local leaderstats = player:WaitForChild("leaderstats") local config = script.Parent.Parent.Parent.Frame.ScrollingFrame.Frame.ImageButton.Config script.Parent.MouseButton1Click:Connect(function() if leaderstats.Diamonds.Value >= config.Cost.Value then leaderstats.Diamonds.Value = leaderstats.Diamonds.Value - config.Cost.Value end end)
this error is because players has that same function and you're indexing it instead of calling it so if you were to do: player(someplayer)
it would work
and if it's in a localscript just use game:GetService('Players').LocalPlayer
-- you didn't finish getplayerfromcharacter. -- from looking at this line, local config = script.Parent.Parent.Parent (if the third parent is the screen GUI) you could do local player = script.Parent (button) .Parent (frame) .Parent (screen gui) .Parent (playergui) .Parent (player)