Touched keyword isnt working for my script

Im trying to make it so If the player has 1 or 1+ slashes they can sell it and convert it into money, the issue is it doesnt work and this comes up.

  14:05:45.090  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:45.091  Stack Begin  -  Studio
  14:05:45.091  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:45.091  Stack End  -  Studio
  14:05:45.093  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:45.094  Stack Begin  -  Studio
  14:05:45.094  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:45.094  Stack End  -  Studio
  14:05:45.420  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:45.421  Stack Begin  -  Studio
  14:05:45.421  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:45.421  Stack End  -  Studio
  14:05:45.421  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:45.421  Stack Begin  -  Studio
  14:05:45.421  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:45.421  Stack End  -  Studio
  14:05:45.422  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:45.422  Stack Begin  -  Studio
  14:05:45.422  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:45.422  Stack End  -  Studio
  14:05:46.286  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:46.287  Stack Begin  -  Studio
  14:05:46.287  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:46.287  Stack End  -  Studio
  14:05:46.387  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:46.387  Stack Begin  -  Studio
  14:05:46.387  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:46.387  Stack End  -  Studio
  14:05:46.387  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:46.387  Stack Begin  -  Studio
  14:05:46.387  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:46.388  Stack End  -  Studio
  14:05:46.503  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:46.503  Stack Begin  -  Studio
  14:05:46.503  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:46.503  Stack End  -  Studio
  14:05:47.370  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.370  Stack Begin  -  Studio
  14:05:47.371  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.371  Stack End  -  Studio
  14:05:47.471  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.471  Stack Begin  -  Studio
  14:05:47.471  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.471  Stack End  -  Studio
  14:05:47.571  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.571  Stack Begin  -  Studio
  14:05:47.571  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.571  Stack End  -  Studio
  14:05:47.572  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.572  Stack Begin  -  Studio
  14:05:47.572  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.572  Stack End  -  Studio
  14:05:47.803  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.803  Stack Begin  -  Studio
  14:05:47.803  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.803  Stack End  -  Studio
  14:05:47.804  Expected ':' not '.' calling member function GetPlayerFromCharacter  -  Server - Sell:5
  14:05:47.804  Stack Begin  -  Studio
  14:05:47.804  Script 'Workspace.SellPart.Sell', Line 5  -  Studio - Sell:5
  14:05:47.804  Stack End  -  Studio

Sell Script

local part = script.Parent
part.Touched:Connect(function(hit)
	local h = hit.Parent:FindFirstChild("Humanoid")
	if h then
		local player = game.Players.GetPlayerFromCharacter(hit.Parent)
	if player then
		local leaderstats = player:WaitForChild("leaderstats")
		local money = leaderstats.Cash
		local selling = leaderstats.Slashes
			if selling.Value >= 0 then
				money.Value = money.Value + selling.Value*1
				selling.Value = 0
		end
	end
	end
end)

leaderstats script

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = player
	
	local slashes = Instance.new("IntValue")
	slashes.Name = "Slashes"
	slashes.Value = 0
	slashes.Parent = stats

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = 0
	coins.Parent = stats

	local stars = Instance.new("IntValue")
	stars.Name = "Stars"
	stars.Value = 0
	stars.Parent = stats
end)

AddSlashes Script

script.Parent.Activated:Connect(function()
	game.Workspace.MainEvent.AddSlashes:FireServer()
	script.Parent.Enabled = false
	wait(1)
	script.Parent.Enabled = true
end)

MainEvent

script.AddSlashes.OnServerEvent:Connect(function(player)
	player.leaderstats.Slashes.Value = player.leaderstats.Slashes.Value +1
end)

This is supposed to be

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

Colon not a period

1 Like

Oh dear everything, GetPlayerFromCharacter is a function, not a property

changed it to that and,

  14:46:42.782  Baseplate auto-recovery file was created  -  Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
  14:47:05.711  Infinite yield possible on 'ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")'  -  Studio
  14:47:05.712  Stack Begin  -  Studio
  14:47:05.712  Script 'Players.NubblyFry.PlayerScripts.ChatScript.ChatMain', Line 51  -  Studio - ChatMain:51
  14:47:05.712  Stack End  -  Studio
  14:47:12.307  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.307  Stack Begin  -  Studio
  14:47:12.307  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.308  Stack End  -  Studio
  14:47:12.309  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.309  Stack Begin  -  Studio
  14:47:12.309  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.310  Stack End  -  Studio
  14:47:12.424  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.424  Stack Begin  -  Studio
  14:47:12.424  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.424  Stack End  -  Studio
  14:47:12.522  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.522  Stack Begin  -  Studio
  14:47:12.523  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.523  Stack End  -  Studio
  14:47:12.639  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.639  Stack Begin  -  Studio
  14:47:12.639  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.640  Stack End  -  Studio
  14:47:12.755  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:12.756  Stack Begin  -  Studio
  14:47:12.756  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:12.756  Stack End  -  Studio
  14:47:13.523  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:13.523  Stack Begin  -  Studio
  14:47:13.524  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:13.524  Stack End  -  Studio
  14:47:13.640  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:13.640  Stack Begin  -  Studio
  14:47:13.640  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:13.641  Stack End  -  Studio
  14:47:13.642  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:13.642  Stack Begin  -  Studio
  14:47:13.642  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:13.642  Stack End  -  Studio
  14:47:13.642  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:13.642  Stack Begin  -  Studio
  14:47:13.643  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:13.643  Stack End  -  Studio
  14:47:13.757  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  14:47:13.757  Stack Begin  -  Studio
  14:47:13.757  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  14:47:13.757  Stack End  -  Studio

You forgot to change Cash to Coins

@StarJ3M meant to make this a reply to you

1 Like
  14:53:36.721  Baseplate auto-recovery file was created  -  Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
  15:31:13.087  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.090  Stack Begin  -  Studio
  15:31:13.091  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.092  Stack End  -  Studio
  15:31:13.097  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.097  Stack Begin  -  Studio
  15:31:13.097  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.098  Stack End  -  Studio
  15:31:13.181  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.181  Stack Begin  -  Studio
  15:31:13.181  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.181  Stack End  -  Studio
  15:31:13.183  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.184  Stack Begin  -  Studio
  15:31:13.184  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.184  Stack End  -  Studio
  15:31:13.188  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.188  Stack Begin  -  Studio
  15:31:13.189  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.189  Stack End  -  Studio
  15:31:13.386  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.386  Stack Begin  -  Studio
  15:31:13.386  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.386  Stack End  -  Studio
  15:31:13.500  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.501  Stack Begin  -  Studio
  15:31:13.501  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.501  Stack End  -  Studio
  15:31:13.502  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.502  Stack Begin  -  Studio
  15:31:13.502  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.502  Stack End  -  Studio
  15:31:13.502  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.502  Stack Begin  -  Studio
  15:31:13.503  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.503  Stack End  -  Studio
  15:31:13.503  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.504  Stack Begin  -  Studio
  15:31:13.505  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.505  Stack End  -  Studio
  15:31:13.505  Cash is not a valid member of Folder "Players.NubblyFry.leaderstats"  -  Server - Sell:8
  15:31:13.505  Stack Begin  -  Studio
  15:31:13.505  Script 'Workspace.SellPart.Sell', Line 8  -  Studio - Sell:8
  15:31:13.506  Stack End  -  Studio

Also, theirs no Cash in leaderstats,

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = player
	
	local slashes = Instance.new("IntValue")
	slashes.Name = "Slashes"
	slashes.Value = 0
	slashes.Parent = stats

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = 0
	coins.Parent = stats

	local stars = Instance.new("IntValue")
	stars.Name = "Stars"
	stars.Value = 0
	stars.Parent = stats
end)
```

I switched it to coins and now it works