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

Why won't my Touch part +100 USD<-- Points script work?

Asked by 5 years ago

Im trying to make a script that if you touch it, it will give you +100 for each time you touch

part = script.Parent
game.Players.PlayerAdded:Connect(function(plr)
    print(plr.Name)
    part.Touched:Connect(function()
    leaderstats = plr:FindFirstChild('leaderstats')
    if leaderstats then
        Yuan = plr:FindFirstChild('Yuan')
        if Yuan then
            Yuan.Value = Yuan.Value + 100
        end
    end
end)

end)

LeaderBoard script

datstore = game:GetService("DataStoreService")
local datast1 = datstore:GetDataStore("Yuan")
local datast2 = datstore:GetDataStore("USD")

game.Players.PlayerAdded:Connect(function(plr)
    local folder = Instance.new("Folder",plr)
    folder.Name = "leaderstats"
    local Yuan = Instance.new("IntValue",folder)
    Yuan.Name = "Yuan"
    local USD = Instance.new("IntValue",folder)
    USD.Name = "USD"
Yuan.Value = datast1:GetAsync(plr.UserId) or 0
datast1:SetAsync(plr.UserId, Yuan.Value)

USD.Value = datast2:GetAsync(plr.UserId) or 0
datast2:SetAsync(plr.UserId, USD.Value)

Yuan.Changed:Connect(function()
    datast1:SetAsync(plr.UserId, Yuan.Value)
end)
USD.Changed:Connect(function()
    datast2:SetAsync(plr.UserId, USD.Value)
end)

end)

0
Mother of god... User#19524 175 — 5y
0
What are you so surprised of TOP_SECRE 28 — 5y
0
Probably the amount of mess that has gone wrong? rochel89 42 — 5y

Answer this question