01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local leaderstats = Instance.new( "Folder" , game.Players.LocalPlayer) |
03 | local Respect = Instance.new( "IntValue" , leaderstats) |
04 | leaderstats.Name = "leaderstats" |
05 | Respect.Name = "Respect" |
06 |
07 |
08 | UserInputService.InputBegan:Connect( function (input, event) |
09 | if input.KeyCode = = Enum.KeyCode.F then |
10 | local audio = workspace:FindFirstChild( "RESPECT THE VETS" ) |
11 | audio.Playing = true |
12 | Respect.Value = Respect.Value + 1 |
13 | end |
14 | 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:
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local leaderstats = Instance.new( "Folder" , player) |
04 | local Respect = Instance.new( "IntValue" , leaderstats) |
05 | leaderstats.Name = "leaderstats" |
06 | Respect.Name = "Respect" --everything works until the line after this |
07 | UserInputService.InputBegan:Connect( function (input, event) --doesnt work |
08 | if input.KeyCode = = Enum.KeyCode.F then |
09 | local audio = workspace:FindFirstChild( "RESPECT THE VETS" ) |
10 | audio.Playing = true |
11 | Respect.Value = Respect.Value + 1 |
12 | end |
13 | end ) |
14 | end ) |
try using making a remove event called "GiveRespect" and then place it on replicated storage then create a server script located on server script service and then make a local script and place it on starter player > starter player scripts
server script:
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local leaderstats = Instance.new( "Folder" , player) |
04 | local Respect = Instance.new( "IntValue" , leaderstats) |
05 | leaderstats.Name = "leaderstats" |
06 | Respect.Name = "Respect" |
07 | end ) |
08 |
09 | game.ReplicatedStorage.GiveRespect.OnServerEvent:Connect( function (plr) |
10 | plr.leaderstats.Respect.Value = plr.leaderstats.Respect.Value + 1 |
11 | end ) |
local script:
01 | local plr = game.Players.LocalPlayer |
02 | local audio = workspace:FindFirstChild( "RESPECT THE VETS" ) |
03 | local UIS = game:GetService( "UserInputService" ) |
04 |
05 | UIS.InputBegan:Connect( function (input) |
06 | if input.KeyCode = = Enum.KeyCode.F then |
07 | audio:Play() |
08 | game.ReplicatedStorage.GiveRespect:FireServer(plr) |
09 | end |
10 | end ) |
also you got an unused parameter on the user input service called "event"