Can you copy and paste the script here so I could fix it for you?
money.Value = money.Value += selling.Value * 1
should be
money.Value += selling.Value * 1
Besides that I don’t think there’s anything else wrong, although not sure why you’re checking if hit
exists
2 Likes
jxmq3s
(james)
May 4, 2021, 3:09pm
#23
I’m unsure how to do the code block because I don’t have the correct things on my keyboard to do it apologies for that.
local Sell = script.Parent
Sell.Touched:Connect(function(hit)
if hit then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats.Coins
local selling = leaderstats.Clicks
if selling.Value > 0 then
money.Value += selling.Value * 1
selling.Value = 0
end
end
end
end)
Use @Ggblocks20 ’s script (sorry gotta make 31 charahrhacters):
Ggblocks20:
Use this code in a normal script:
-- When a player touches the parent object, their items will be sold for gold
local sellPart = script.Parent
-- Gives the player gold for each item they have
local function sellItems(playerItems, playerGold)
-- Gives players 10 pieces of gold for each item
local totalSell = (playerItems.Value * 10)
playerGold.Value = playerGold.Value + totalSell
playerItems.Value = 0
end
local function onTouch(partTouched)
-- Looks for a Humanoid
local character = partTouched.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
-- If a humanoid is found, gets leaderstats and calls sellItems function
if humanoid then
-- Get the player, so changes can be made to the player's leaderstats
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
local playerStats = player:FindFirstChild("leaderstats")
local playerItems = playerStats:FindFirstChild("Clicks")
local playerGold = playerStats:FindFirstChild("Coins")
-- Sells Items and then changes the player's spaces and money
sellItems(playerItems, playerGold)
end
end
sellPart.Touched:Connect(onTouch)
jxmq3s
(james)
May 4, 2021, 3:12pm
#25
I have tried this but it’s not working and output doesn’t say anything.
Screenshot your explorer.