Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i get my burger to sell for cash?

Asked by
fastlocks -10
4 years ago
Edited by Ziffixture 4 years ago

I made a makeable burger now I want it to be able to sell when touched if the parent name is 'Normal Burger'

Here is the script:


script.Parent.Touched:Connect(function(Hit) if Hit.Parent.Name == 'Normal Burger ' then local player = game.Players:GetPlayerFromCharacter(Hit.Parent) if player then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value +1 end end end)

PS. I am very new and barely know what I am doing/ D;

1
I formatted your code because it wasn't in a code-block. I then realized you're missing an 'end' so I fixed it, if that's what you're looking for, try the code above again. Ziffixture 6913 — 4y
0
I tried the script nothing happened, the player.leaderstats.Cash.Value +1 bit is underlined in red and it is not telling me what is wrong fastlocks -10 — 4y
0
To properly modify a property, you can use the assignment operator, otherwise known as =. To perform an add-to operator—similarly seen as += in other languages—you have to take the current state of the value you with to increment and add to it; take the example below.  Ziffixture 6913 — 4y
0
player.leaderstats.Cash.Value = player.Leaderstats.Cash.Value + 1 Ziffixture 6913 — 4y
View all comments (3 more)
0
Nevermind i fixed the red underline under the = but when the burger and the part touches it still isn't giving me any cash :( fastlocks -10 — 4y
0
Have you tried putting a print statement in the if statement to see if it runs? In the script above, you've included a white space when checking for the name("Normal Burger " instead of "Normal Burger"). Maybe this is what's causing the issue sydre 229 — 4y
0
i forgot how to add a print thing lol i give up i guess cause wasting to much of your guys time, but 1 last go Script: script.Parent.Touched:Connect(function(Hit) if Hit.Parent.Name == 'Normal Burger' then local player = game.Players:GetPlayerFromCharacter(Hit.Parent) if player then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1 end end end) fastlocks -10 — 4y

Answer this question