Hio! So, as you can see this is all about scripting! So, i obviously have many many questions when it comes down to scripting, as you all know.. lol. So lets get this party started!
First off, i am trying to make a custom LB(LeaderBoard) This leaderboard will eventually and hopefully connecting in with the Teams set up. I havent gotten that far yet... ya, i know... So, heres the script, with the thoughts after it:
print("BattleFront2SpaceMapLeaderBoardActivatedCommander")
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local mins = Instance.new("IntValue")
mins.Name = "Time"
mins.Value = 15
local Point = Instance.new("IntValue")
Point.Name = "Point"
Point.Value = 0
local Round = Instance.new("IntValue")
Round.Name = "Round"
Round.Value = 0
mins.Parent = stats
Point.Parent = stats
Round.Parent = stats
while true do
if newPlayer.Character ~= nil then break end
wait(5)
end
local humanoid = newPlayer.Character.Humanoid
stats.Parent = newPlayer
end
while true do
wait(60)
mins.Value = mins.Value - 1
if mins.Value == 0 then
print("game over")
end
end
game.Players.ChildAdded:connect(onPlayerEntered)
So, anyways its very basic and incomplete at the moment, i am going to add more later... but the problem is the LB never shows up... it just has my name under the player list, and the values dont come up. So, my question is why? I believe i have followed most of all the steps that the other ones do. I have been using other LBs to base mines off of... isnt working obviously.
So, thats problem number 1, here is number 2. I am trying to make a detonation bomb. This could be very fun, very fun indeed. So, to start it off i tried moving all of the contents fromt he bomb script into the plantbomb script... not sure if that was a good idea... So, i did that then started to change somethings around, so here is the current script for it:
print("Bomb hopper script loaded")
bin = script.Parent
bombScript = script.Parent.Bomb
currentColor = 1
colors = {26, 21}
ticksound = Instance.new("Sound")
ticksound.SoundId = "rbxasset://sounds\\clickfast.wav"
ticksound.Parent = script.Parent
function blowUp()
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds\\Rocket shot.wav"
sound.Parent = script.Parent
sound.Volume = 1
sound:play()
explosion = Instance.new("Explosion")
explosion.BlastRadius = 12
explosion.BlastPressure = 1000000 -- these are really wussy units
-- find instigator tag
local creator = script.Parent:findFirstChild("creator")
if creator ~= nil then
explosion.Hit:connect(function(part, distance) onPlayerBlownUp(part, distance, creator) end)
end
explosion.Position = script.Parent.Position
explosion.Parent = game.Workspace
script.Parent.Transparency = 1
end
function onPlayerBlownUp(part, distance, creator)
if part.Name == "Head" then
local humanoid = part.Parent:findFirstChild("Humanoid")
tagHumanoid(humanoid, creator)
end
end
function tagHumanoid(humanoid, creator)
-- tag does not need to expire iff all explosions lethal
if creator ~= nil then
local new_tag = creator:clone()
new_tag.Parent = humanoid
end
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end
function plant()
local bomb = Instance.new("Part")
local spawnPos = game.Players.LocalPlayer.Character.PrimaryPart.Position
bomb.Position = Vector3.new(spawnPos.x, spawnPos.y+3, spawnPos.z)
bomb.Size = Vector3.new(2,2,2)
bomb.BrickColor = BrickColor.new(21)
bomb.Shape = 0
bomb.BottomSurface = 0
bomb.TopSurface = 0
bomb.Reflectance = 1
bomb.Name = "TimeBomb"
bomb.Locked = true
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = game.Players.LocalPlayer
creator_tag.Name = "creator"
creator_tag.Parent = bomb
bomb.Parent = game.Workspace
local new_script = bombScript:clone()
new_script.Disabled = false
new_script.Parent = bomb
end
detonation = false
enabled = true
function onButton1Down(mouse)
if not enabled and detonation == false then
return
end
enabled = false
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
plant()
ticksound:play()
wait(1)
mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
detonation = true
if detonation == true then
function onButton2Down(mouse)
wait(0.1)
blowUp()
end
end
wait(1)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
enabled = true and
detonation == false
end
function onSelected(mouse)
print("bomb selected")
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
wait(2)
bombScript:remove()
bin.Selected:connect(onSelected)
Yes, i know its big when its all put together... I did that because i thought, that i would be able to set up a second onMouseblahblah function and i would need to blow script in here to create the explosion... I wanted to make it so that if you would click on mouse button1 then the bomb would appear, the bomb wouldnt do anything untill you clicked on the mouse button again and then the bomb would detonate. Obviously, if you look, i am trying to set it up so if you click mouse button number 2... I did that instead of mouse button 1 because i always get confused when trying to make two functions of the same type in one script. I was going to try and make that for the mouse button 1 again after i completed the script. So, now to the problem of the script. It never works, i click and nothing happens... i was wondering if someone could point me in the right direction though... Seeing as how everything i do never works, but it never says there is a error.
Koopa |