Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Teleport and give 35+ money pad?

Absolutely nothing happens when I step on it.

Scroll down for error, Leaderboard, Pad script.

Leaderboard script / Normal script in workspace.

game.Players.PlayerAdded:connect(function(player)
	
	local stats = Instance.new("IntValue", player)
	stats.Name = "leaderstats"
	
	local points = Instance.new("IntValue", stats)
	points.Name = "points"
	
	local ingame = Instance.new("BoolValue", player)
	ingame.Name = "InGame"
end)

Main teleport + money giver script / Inside a model and a normal script.

local Players = game.Players
local enabled = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then
        for i,v in pairs(Players:GetChildren()) do
            if v.Name == hit.Parent.Name then
                plrobj = v -- The player inside "Players"
                local points = plrobj.leaderboard:FindFirstChild("points")
                if enabled == true then
                    hit.Parent:MoveTo(game.Workspace.LobbySpawn.Position)
                    points.Value = points.Value + 35
                    enabled = false
                    wait(1)
                    enabled = true
                end
            end
        wait()
        end
    end
end)

Error

21:12:12.143 - leaderboard is not a valid member of Player

2 comments

0

It's "leaderstats" and not "leaderboard"

0

Because the name is "leaderstats" it won't find anything named "leaderboard".

2 answers

Please refresh the page If your typing right now, made some changes.

You typed "leaderboard" not "leaderstats" and :connect is deprecated. use :Connect. and you can get player with :GetPlayerFromCharacter(hit.Parent)

put your leaderstats script in ServerScriptService

here is fixed script:

local Players = game.Players
local enabled = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then
    local v = Players:GetPlayerFromCharacter(hit.Parent)
    if v then
        local plrobj = v
        local points = plrobj.leaderstats:FindFirstChild("points")
			if enabled == true then
				hit.Parent:MoveTo(game.Workspace.LobbySpawn.Position)
				points.Value = points.Value + 35
				enabled = false
				wait(1)
				enabled = true
			end
    	end
    end
end)

Hope it helped :)

errors? tell-me on comments.

(Solved your problems? put in title [SOLVED] or accept a answer.)

2 comments

0

Thank you so much gentle person.

0

Soon i can play this with my viewers, It will be amazing!

This discussion is preserved as it was. New answers, comments, and votes are closed.