X888X
|
  |
| Joined: 08 Oct 2011 |
| Total Posts: 243 |
|
|
| 11 Feb 2012 05:27 PM |
Hello, I need help making a shop, here's the 2 scripts I have that the shop wont take...
The KO, WO, CASH SCRIPT:
print("X888X's Leaderboard script loaded")
stands = {}
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue") stats.Name = "leaderstats" local kills = Instance.new("IntValue") kills.Name = "Knockouts" kills.Value = 0 local spree = Instance.new("IntValue") spree.Name = "Spree" spree.Value = 999 local deaths = Instance.new("IntValue") deaths.Name = "Whipouts" deaths.Value = 0 local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 9999999 cash.Parent = stats kills.Parent = stats deaths.Parent = stats
spree.Parent = stats
local ai = Instance.new("ObjectValue") ai.Name = "AI" local ai1 = Instance.new("StringValue") ai1.Name = "1" ai1.Parent = ai if newPlayer.Name == "X888X" then ai1.Value = "X888X" end local ai2 = Instance.new("StringValue") ai2.Name = "2" ai2.Parent = ai
while true do if newPlayer.Character ~= nil then break end wait(5) end
local humanoid = newPlayer.Character.Humanoid
humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )
newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
stats.Parent = newPlayer ai.Parent = newPlayer
if newPlayer.TeamColor == BrickColor.new("Bright green") then givePack(newPlayer,"Bright green") end if newPlayer.TeamColor == BrickColor.new("Bright yellow") then givePack(newPlayer,"Bright yellow") end end
function Send_DB_Event_Died(victim, killer)
local killername = "no one" if killer ~= nil then killername = killer.Name end
print("DIED EVENT: ", victim.Name, " KILLED by ", killername)
if shared["deaths"] ~= nil then shared["deaths"](victim, killer) print("SENT DB DEATH EVENT") end end
function Send_DB_Event_Kill(killer, victim) print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name)
game.Workspace.kill:findFirstChild("c1").Value = game.Workspace.kill:findFirstChild("b1").Value game.Workspace.kill:findFirstChild("b1").Value = game.Workspace.kill:findFirstChild("a1").Value if victim.Name == "X888X" then game.Workspace.kill:findFirstChild("a1").Value = killer.Name.." Killed *Creator: "..victim.Name.."*" else game.Workspace.kill:findFirstChild("a1").Value = killer.Name.." Killed "..victim.Name end
if shared["kills"] ~= nil then shared["kills"](killer, victim) print("SENT DB KILL EVENT") end end
function onHumanoidDied(humanoid, player) handleKillCount(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats ~= nil then local deaths = stats:findFirstChild("Whipouts") local spree = stats:findFirstChild("Spree") deaths.Value = deaths.Value + 1 wait(1) spree.Value = 0
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
Send_DB_Event_Died(player, killer)
end end
function onPlayerRespawn(property, player)
if property == "Character" and player.Character ~= nil then ---------------------------------------------------------------------------------------------------------------------- if player.TeamColor == BrickColor.new("Bright green") then givePack(player,"Bright green") end if player.TeamColor == BrickColor.new("Bright yellow") then givePack(player,"Bright yellow") end ---------------------------------------------------------------------------------------------------------------------- local humanoid = player.Character.Humanoid local p = player local h = humanoid humanoid.Died:connect(function() onHumanoidDied(h, p) end )
end end
function givePack(player,team) character = player.Character Type = game.Lighting:findFirstChild("BackP") if character:findFirstChild("Humanoid") ~= nil then if character:findFirstChild("Chest") == nil then local g = Type.Chest:clone() g.Parent = character local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = character.Torso Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 g.Middle.Transparency = 1 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false h[i].Locked = true h[i].BrickColor = BrickColor.new(team) end end end end
function getKillerOfHumanoidIfStillInGame(humanoid)
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
local killer = tag.Value if killer.Parent ~= nil then return killer end end
return nil end
function handleKillCount(humanoid, player) wait(0.1) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("leaderstats") if stats ~= nil then local kills = stats:findFirstChild("Knockouts") local spree = stats:findFirstChild("Spree") local cash = stats:findFirstChild("Cash") if (killer.TeamColor ~= player.TeamColor) then if player.Name == "X888X" then kills.Value = kills.Value + 1 wait() spree.Value = spree.Value + 1 wait() cash.Value = cash.Value + 360 else kills.Value = kills.Value + 1 wait() spree.Value = spree.Value + 1 wait() cash.Value = cash.Value + 200 end else killer.Character.Head:remove() wait() kills.Value = kills.Value - 1 wait() spree.Value = spree.Value - 1 wait() cash.Value = cash.Value - 120 end Send_DB_Event_Kill(killer, player) end end end
function findAllFlagStands(root) local c = root:children() for i=1,#c do if (c[i].className == "Model" or c[i].className == "Part") then findAllFlagStands(c[i]) end if (c[i].className == "FlagStand") then table.insert(stands, c[i]) end end end
function hookUpListeners() for i=1,#stands do stands[i].FlagCaptured:connect(onCaptureScored) end end
function onCaptureScored(player) for i,v in pairs(game.Players:GetChildren()) do if v.TeamColor == player.TeamColor then local ls = v:findFirstChild("leaderstats") if ls == nil then return end local cash = ls:findFirstChild("Cash") if cash == nil then return end cash.Value = cash.Value + 600 end end m=Instance.new("Message") m.Parent=game.Workspace m.Text = player.Name.." Captured , Whole team + 600 cash." game.Debris:AddItem(m,4) end
findAllFlagStands(game.Workspace) hookUpListeners() game.Players.ChildAdded:connect(onPlayerEntered)
for i,v in pairs(game.Players:GetChildren()) do onPlayerEntered(v) end
The Shop script to buy:
player = script.Parent.Parent.Parent.Parent.Parent --Leave that alone gold = player.leaderstats.Cash --Change points to your Currency upgradeStuff = game.Lighting.Sniper1 --Change Sniper1 to the name of the Tool and place the tool in Lighting function buy() if gold.Value >= 700 then --Change 700 To price gold.Value = gold.Value - 700 --Change 700 to same price as above --Leave the rest alone local a = upgradeStuff:clone() a.Parent = player.Backpack end end script.Parent.MouseButton1Down:connect(buy)
please help me fix this!!! |
|
|
| Report Abuse |
|