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

I need help with this "Get cash from coin script" whilist printing no errors?

Asked by 3 years ago

Code:

coin = script.Parent

local player = game:GetService("Players")

local Stats = Instance.new("IntValue")
Stats.Parent = player
Stats.Name = "leaderstats"


-- Variables

game.Players.PlayerAdded:Connect(function()
    coin.Touched:Connect(function()
        player.leaderstats.Value = player.leaderstats.Value + 1
        wait(2)
        coin.Transparency = 1
    end)
end)

-- Function


print("Worked")

It printed 0 errors, please help!

0
So is this script in the coin or serverscriptservice?  The leaderstats should be in the serverscriptservice and the touch to get money should be in the coin baseballcal15 0 — 3y
0
Okay! Let me try it. Ponytails2017 83 — 3y
0
Didn't work Ponytails2017 83 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

—This should be in serverscriptservice

game.players.playeradded:Connect(function(player)

  local leaderstats = Instance.new(“Folder”)
  leaderstats.Name = “leaderstats”
  leaderstats.Parent = player

 local Coins = Instance.new(“IntValue”)
 Coins.Name = “Coins”
 Coins.Parent = leaderstats 

end)

—This should be in the coin

script.Parent.Touched:Connect(function(hit) local player = game.Players.FindFirstChild(hit.Parent.Name) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10 -- Amount you get script.Parent.Parent = game.ServerStorage wait(5) -- how much seconds to wait after collecting again script.Parent.Parent = game.Workspace end)

0
Didn't work / errored. Next time put it inside a code block. Ponytails2017 83 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

this should be inside the server script service

game.Players.Playeradded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
     leaderstats.Name = “leaderstats”
     leaderstats.Parent = player

    local Coins = Instance.new(“IntValue”)
    Coins.Name = “Coins”
    Coins.Parent = leaderstats
end)

this should be in the coin

Script.parent.Touched:Connect(function(hit)
    if game.Players:GetPlayerfromCharacter (hit.Parent) then
        local  TouchedPlayer = game.Players:GetPlayerfromCharacter (hit.Parent)
        local CoinValue = TouchedPlayer.leaderstats.Coins.Value
        CoinValue = CoinValue + 1
        Script.Parent:Destroy
    end
end)

i didn't test this so don't blame me if it doesn't work

0
This should work sorry first time on this website still learning how to use it baseballcal15 0 — 3y
0
The leaderstats worked after fixing many spelling errors. The other code did not work and errored multiple times with spelling errors Ponytails2017 83 — 3y
0
The leaderstats worked after fixing many spelling errors. The other code did not work and errored multiple times with spelling errors Ponytails2017 83 — 3y

Answer this question