local UserInputService = game:GetService("UserInputService")
local leaderstats = Instance.new("Folder", game.Players.LocalPlayer)
local Respect = Instance.new("IntValue", leaderstats)
leaderstats.Name = "leaderstats"
Respect.Name = "Respect"
UserInputService.InputBegan:Connect(function(input, event)
if input.KeyCode == Enum.KeyCode.F then
local audio = workspace:FindFirstChild("RESPECT THE VETS")
audio.Playing = true
Respect.Value = Respect.Value + 1
end
end)
this script works mostly, what happens in game when I use it is: -creates the leaderstats value and folder -when clicked F it plays the noise but what doesnt work is: -value doesnt have the correct name on the leaderboard -value does not increase
there is no output errors. it is in a localscript inside of StarterGui if you want to know that i will be glad to elaborate
modified version, server script in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
local UserInputService = game:GetService("UserInputService")
local leaderstats = Instance.new("Folder", player)
local Respect = Instance.new("IntValue", leaderstats)
leaderstats.Name = "leaderstats"
Respect.Name = "Respect" --everything works until the line after this
UserInputService.InputBegan:Connect(function(input, event) --doesnt work
if input.KeyCode == Enum.KeyCode.F then
local audio = workspace:FindFirstChild("RESPECT THE VETS")
audio.Playing = true
Respect.Value = Respect.Value + 1
end
end)
end)

1 comment
maybe try creating the leaderstats and value on the server. might be one of the causes.