Hello.
You cannot have spaces be used like that when you are trying to add to values.
I also recommend adding a Debounce to your script, so that the values aren't added more than once.
Assuming that your leaderstats is located in the Player's character, this is what the script should look like:
local PartTouch = 1
local Debounce = false
local Players = game:GetService("Players")
local Cooldown = 1
local function PartTouched(Collision)
if not (Debounce) then
Debounce = true
local Humanoid = Collision.Parent:FindFirstChildWhichIsA("Humanoid")
if (Humanoid) then
local Player = Players:GetPlayerFromCharacter(Collision.Parent)
if (Player) then
local Leaderstats = Player.Character.leaderstats
local Keys = Leaderstats:WaitForChild("keys keys")
Keys.Value += 1
end
end
wait(Cooldown)
Debounce = false
end
end
workspace.Part.Touched:Connect(PartTouched)
Hope this works for you.
3 comments
dude, can you arrange you code well put it inside the Squiggly lines when you click the code block button
what is the error?
They have put a space in between the "keys keys" part.