generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Disaster point coin giver

Previous Thread :: Next Thread 
jared1st is not online. jared1st
Joined: 08 Mar 2009
Total Posts: 116
19 Aug 2012 08:21 AM
((can any one make me a coin that works with my point giveing thing for my Disaster map i wanted to make it so they could get coins at random times.))

bin = script.Parent


bin = script.Parent

---------- For Announcing Who Survived
feedbackEnabled = true
function feedback(parent, message)
if not feedbackEnabled then return end
local h = parent:findFirstChild("announcement")
if h ~= nil then
h.Text = message
else
h = Instance.new("Message")
h.Name = "announcement"
h.Text = message
h.Parent = parent
end
end

function removeFeedback(parent, delay)
local h = parent:findFirstChild("announcement")
if h ~= nil then
local txt = h.Text
wait(delay)
if h ~= nil and h.Text == txt then -- Make sure that there is not more feedback.
h:remove()
end
end
end

function compilePlayers(players)
local names = ""
if #players == 1 then return players[1].Name end
for i=1,#players do
if i == #players then
names = names.. "and ".. players[i].Name
else
names = names.. players[i].Name.. ", "
end
end
return names
end
----------

function setTag(parent, type, name, value)

local tag = parent:findFirstChild(name)
if tag ~= nil then
if tag.className == type then
tag.Value = value
else
local newTag = Instance.new(type)
newTag.Name = name
newTag.Value = value
newTag.Parent = parent
end
else
local newTag = Instance.new(type)
newTag.Name = name
newTag.Value = value
newTag.Parent = parent
end
end

function getTag(parent, type, name, default)

local tag = parent:findFirstChild(name)
if tag ~= nil then
if tag.className == type then
return tag.Value
else
print("No tag of the specified name and class was found in ", parent)
return default
end
else
print("No tag named ", name, " found in ", parent)
return default
end
end

function died(player, humanoid)
if player ~= nil then
if humanoid ~= nil then
if humanoid.Health == 0 then
setTag(player, "BoolValue", "survived", false)
end
else
setTag(player, "BoolValue", "survived", false)
end
end
end

running = true
function start()
local players = game.Players:getChildren()
local connections = {}

running = true

for i=1,#players do
if players[i].Character ~= nil then
setTag(players[i], "BoolValue", "survived", true)
table.insert(connections, players[i].Character.Humanoid.Changed:connect(function () died(players[i], players[i].Character.Humanoid) end))
end
end

while running do
wait(1)
end

players = game.Players:getChildren()
local survivedt = {}

for i=1,#players do
local survived = getTag(players[i], "BoolValue", "survived", false)
if survived then
setTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Survivals", getTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Survivals", 0) + 1)
setTag(players[i]:findFirstChild("leaderstats"), "IntValue", "points", getTag(players[i]:findFirstChild("leaderstats"), "IntValue", "points", 0) + bin.points.Value)
table.insert(survivedt, players[i])
end
end
bin.points.Value = 0



for i=1,#connections do -- Disconnect all previous connections.
connections[i]:disconnect()
end

if #survivedt > 0 then
feedback(game.Workspace, compilePlayers(survivedt).. " survived.")
else
feedback(game.Workspace, "Nobody Survived!")
end
removeFeedback(game.Workspace, 3)
end

function runningChanged(run)
print("Running Changed")
if run.Value == true then
start()
else
running = false
end
end

function newPlayer(player)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"

local points = Instance.new("IntValue")
points.Name = "points"
points.Value = 0

local survivals = Instance.new("IntValue")
survivals.Name = "Survivals"
survivals.Value = 0

points.Parent = stats
survivals.Parent = stats
stats.Parent = player
end

game.Players.ChildAdded:connect(newPlayer)
bin.running.Changed:connect(function () runningChanged(bin.running) end)
print("Leaderboard Loaded")
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
19 Aug 2012 08:22 AM
Search up point giver and u will see coin.
Report Abuse
jared1st is not online. jared1st
Joined: 08 Mar 2009
Total Posts: 116
19 Aug 2012 08:25 AM
I have tryed but i cant get it to work with my scritpy set up :c could you help me out?
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
19 Aug 2012 08:31 AM
Ok you got the gold coin. Tell me

1. What intvalue do you want to change? points?

2. Is points spelt "points" or "Points" ?
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
19 Aug 2012 08:34 AM
Replace

local points = Instance.new("IntValue")
points.Name = "points"
points.Value = 0

With

local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0

It really depends on your coin script. Try this first.
Report Abuse
jared1st is not online. jared1st
Joined: 08 Mar 2009
Total Posts: 116
19 Aug 2012 08:54 AM
okay for the scripts there is the

LeaderboardScript and the Get Cash script (this is all in that coin)


(leaderboard script)

function Entered(player)
wait()

if player:findFirstChild("leaderstats") ~= nil then
player.leaderstats:remove()
end

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

money = Instance.new("IntValue")
money.Parent = stats
money.Name = "Coin/s"
money.Value = 0

end

game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
Entered(c[i])
end


(get cash script)
amnt = 1 --how much you get for it
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Points")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
19 Aug 2012 01:21 PM
Ok leaderbosrd script replace

money = Instance.new("IntValue")
money.Parent = stats
money.Name = "Coin/s"

With

money = Instance.new("IntValue")
money.Parent = stats
money.Name = "Points"

And for the coin script if you want the coin to go away sfter someone touches it the script you have is ok if you do not want the coin to go away remove the line

script.Parent:remove()

Hope it works now
Report Abuse
jared1st is not online. jared1st
Joined: 08 Mar 2009
Total Posts: 116
19 Aug 2012 05:49 PM
could you just make me a coin that works for my map please ;n; i will give you 300 robuxs for it.
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
19 Aug 2012 06:16 PM
put in coin:

-- this script will not remove the coin but reactivate it after 1sec
bounce = false
function onTouched(part)
if bounce == false then
bounce = true
local h = part.Parent:findFirstChild("Animate")
if (h and h.Parent.Humanoid.Health >= 10) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Points")
if (score~=nil) then
score.Value = score.Value + 10 --change to amount
--game.Workspace:FindFirstChild(h.Parent.Name).Torso.CFrame = CFrame.new(63.5, 120, -6)
wait(1)
bounce = false
end
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

or this script

-- this script will remove the coin after touch
bounce = false
function onTouched(part)
if bounce == false then
bounce = true
local h = part.Parent:findFirstChild("Animate")
if (h and h.Parent.Humanoid.Health >= 10) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Points")
if (score~=nil) then
score.Value = score.Value + 10 --change to amount
--game.Workspace:FindFirstChild(h.Parent.Name).Torso.CFrame = CFrame.new(63.5, 120, -6)
wait(1)
script.Parent:remove()
bounce = false
end
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

the script will change leaderboard "Points"
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image