I am making a simulator game, and I want to make a button that if the player stands on it, then it adds the strength and weight they have, sets it to zero, then gives them the two stats added to their money
also this script is in ChracterScripts
here is the script
local Character = script.Parent
local player = game.player:WaitForChild(Character)
local humanoid = Character:WaitForChild("Humanoid")
local touchedConnection = humanoid.Touched:Connect(function(hit, limb)
if hit.Name == 'Sell' then
local Total = player.leaderstats.Weight.Value + player.leaderstat.Strength.Value
local Money = player.leaderstats.Money
Money.Value = Money.Value + Total
player.leaderstats.Weight.Value = 0
player.leaderstats.Strength.Value = 0
end
end)
Well your script have a lot of errors. I guess your problem is that it won’t minus or plus to any of the stat.
First, you write the player service wrong. It is supposed to be Players, and the character probably hasn’t finished loading so character doesn’t exist?correct me if i’m wrong. Add a wait before it(yes i know bad practise).
Second, which I should have mentioned first, why don’t you make a normal script in the button that gets touched instead making a script in StarterCharacter?
the character would’ve already loaded otherwise a .Touched wouldn’t be possible. It’s mainly just typo errors
Also @twitchman123 can you please tell us what errors are actually popping up, other than these typos we don’t really know what your problem is with the code.