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 » Scripters
Home Search
 

Re: Scripting Help Please!

Previous Thread :: Next Thread 
Jalandrian is not online. Jalandrian
Joined: 23 Mar 2012
Total Posts: 3581
02 Nov 2015 03:11 PM
Im using Davidiis Scripting And This Comes Up As A No Screengui Error.


function cleanGui()
local player, char = getPC()
local playerGui = player.PlayerGui
local screenGui = playerGui.ScreenGui
local guis = screenGui:GetChildren()

This Is The Script Part In Which The Error States "This Is The Line Were The Error Occured"


Any Help?
Report Abuse
Jalandrian is not online. Jalandrian
Joined: 23 Mar 2012
Total Posts: 3581
02 Nov 2015 03:12 PM
Full Script.





local tool = script.Parent
local config = tool.Configuration
local debounce = true

--blunt weapon stuff
local clothingChoices = {"Torso", "Torso", "Arms", "Legs", "Head"}

function weightTable(tab, item, weight)
for weighting = 1, weight do
table.insert(tab, item)
end
end

--fishing stuff
local fishing = false
local fishChoices = {}
local total = 5000
weightTable(fishChoices, "Salmon", total * 0.5) --50 percent used
weightTable(fishChoices, "Tuna", total * 0.1) --60 percent used
weightTable(fishChoices, "Trout", total * 0.2) --80 percent used
weightTable(fishChoices, "Cod", total * 0.19) --99 percent used
weightTable(fishChoices, "Bugshark", total * 0.01) --100 percent :D

--global gui stuff
function guiAlert(text, time)
local player, char = getPC()
local playerGui = player.PlayerGui
local screenGui = playerGui.ScreenGui

local textLabel = Instance.new("TextLabel")
textLabel.BackgroundColor3 = Color3.new(0, 0, 0)
textLabel.BorderColor3 = Color3.new(0, 0, 0)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.TextWrapped = true
textLabel.Text = text
textLabel.Parent = screenGui

textLabel:TweenSizeAndPosition(UDim2.new(0, 240, 0, 120), UDim2.new(0, 80, 0, 80))

delay(time, function()
textLabel:TweenSizeAndPosition(UDim2.new(0, 0, 0, 0), UDim2.new(0, 0, 1, 0))
wait(1)
textLabel:remove()
end)
end

function getPC()
local character = tool.Parent
local player = nil

if character:IsA("Model") then
player = game.Players:GetPlayerFromCharacter(character)
else
player = character.Parent
character = player.Character
end

return player, character
end

function setWalkSpeed(walkSpeed)
local player, char = getPC()
local humanoid = char.Humanoid

humanoid.WalkSpeed = walkSpeed
end

function chance(number)
return (math.random(1, number) == 1)
end

function getType()
local type = config.Type

return type.Value
end

function getRange()
local range = config.Range

return range.Value
end

function getDamage()
local damage = config.Damage

return damage.Value
end

function getSpeed()
local speed = config.Speed

return speed.Value
end

function getQuality()
local quality = config.Quality

return quality.Value
end

function getDurability()
local durability = config.Durability

return durability.Value
end

function getCondition()
local condition = tool.Condition

return condition.Value
end

function getAmmoType()
local ammoType = config.AmmoType

return ammoType.Value
end

function debouncing(time)
delay(0, function()
debounce = false
wait(time)
debounce = true
end)
end

function swingAnimation()
local swing = Instance.new("StringValue")
swing.Name = "toolanim"
swing.Value = "Slash"
swing.Parent = tool
end

function takeWeldedParts(part)
local player, char = getPC()

local welds = part:GetChildren()

for index, child in pairs(welds) do
if child.className == "Weld" then
child.Part1.Parent = player.Inventory
child:remove()
end
end
end

function removeAllWelds(part)
local welds = part:GetChildren()

for index, child in pairs(welds) do
if child:IsA("Weld") then
child:remove()
end
end
end

function getCellLocation(part)
local underground = game.Workspace.Underground
local distancer = underground.Distancer.Value
local scale = underground.Scale.Value
local cellLocation = (part.Position - distancer) / scale

return cellLocation
end

function mineUnderground(part)
local underground = game.Workspace.Underground
local requests = underground.Requests

local req = Instance.new("Vector3Value")
req.Name = "Mine"
req.Value = getCellLocation(part)
req.Parent = requests
end



function meleeWeapon(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local humanoid = part.Parent:findFirstChild("Humanoid")

if humanoid ~= nil then
humanoid:TakeDamage(getDamage())

use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function pierceWeapon(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local humanoid = part.Parent:findFirstChild("Humanoid")

if humanoid ~= nil then
local percentage = getDamage() / 100
local damage = humanoid.MaxHealth * percentage

humanoid:TakeDamage(damage)

use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function bluntWeapon(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local humanoid = part.Parent:findFirstChild("Humanoid")

if humanoid ~= nil then
humanoid:TakeDamage(getDamage())

use()

if chance(10) then
_G.unequipRequest(clothingChoices[math.random(1, #clothingChoices)], part.Parent)
end
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function thrownWeapon(mouse)

end

function lockpickingTool(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local lockCheck = part.Parent:findFirstChild("LockModel")

if lockCheck ~= nil then
if chance(getQuality()) then
part.Parent:remove()
end

use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function miningTool(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local mining = part.Parent:findFirstChild("Mining")

if mining ~= nil then
if mining.Value == "Surface" then
if chance(getQuality()) then
takeWeldedParts(part)

part.Parent = player.Inventory
end
else
mineUnderground(part)
end

use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function woodcuttingTool(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Parent ~= nil then
local woodcutting = part.Parent:findFirstChild("Woodcutting")

if woodcutting ~= nil then
part.Parent = player.Inventory
removeAllWelds(part)

use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function threshingTool(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Name == "Wheat" then
local grain = game.Lighting.Items.Items.Grain

if grain ~= nil then
part:remove()
grain:clone().Parent = player.Inventory
use()
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function skinningTool(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
local skinningCheck = part:findFirstChild("Skinning")

if skinningCheck ~= nil then
local hideName = skinningCheck.HideName.Value
local meatName = skinningCheck.MeatName.Value
local hide = game.Lighting.Items.Items:findFirstChild(hideName)
local meat = game.Lighting.Items.Items:findFirstChild(meatName)

if hide ~= nil then
if meat ~= nil then
hide:clone().Parent = player.Inventory
meat:clone().Parent = player.Inventory

part:remove()

use()
end
end
end
end
end

swingAnimation()

debouncing(getSpeed())
end

function lightingTool()
if not debounce then return end

debounce = false
tool.CanBeDropped = false

local player, char = getPC()

local light = Instance.new("PointLight")
light.Name = "Light"
light.Range = 24
light.Parent = char.HumanoidRootPart

while true do
use()
wait(1)
end
end

function ammunitionWeapon(mouse)
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p
local ammoPicked = false

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
local ammoCheck = part:findFirstChild(getAmmoType())

if ammoCheck ~= nil then --it's an ammo pickup!
if player:DistanceFromCharacter(mousePos) < 6 then --only pickup at melee range >:O
ammoPicked = true

local ammoAdded = ammoCheck.Value
local condition = tool.Condition

condition.Value = condition.Value + ammoAdded + 1 --add one so I can cheat the use() function to show new ammo

part:remove()

use()
end
else
if getCondition() > 0 then --if I have ammo
if part.Parent ~= nil then --if the player exists
local humanoid = part.Parent:findFirstChild("Humanoid")

if humanoid ~= nil then
humanoid:TakeDamage(getDamage())
end
end

shotLine(tool.Handle.Position, mousePos, "White") --fancy thing
use() --sorry, you click, you shoot
end
end
end
end

if ammoPicked then
debouncing(0.25)
else
debouncing(getSpeed())
end
end

function fishingTool(mouse)
if fishing then fishing = false end
if not debounce then return end

local player, char = getPC()
local mousePos = mouse.hit.p

if player:DistanceFromCharacter(mousePos) < getRange() then
local part = mouse.Target

if part ~= nil then
if part.Name == "Ocean" then
local finishedFishing = true

--cast that line! Cast it far!
swingAnimation()

--the "fishing" part
debounce = false
fishing = true

for timing = 1, math.random(1, getSpeed()), 0.1 do
setWalkSpeed(0)
shotLine(tool.Handle.Position, mousePos, "White")
wait(0.1)

if not fishing then
finishedFishing = false
break
end
end

debounce = true
fishing = false
setWalkSpeed(char.WalkSpeedContainer.Value)

--he's fished, which means... I dunno, the string got worn or something
use()

--now to see if he caught one
if chance(getQuality()) and finishedFishing then
local fishName = fishChoices[math.random(1, #fishChoices)]
local fish = game.Lighting.Fish:findFirstChild(fishName)

if fish ~= nil then
fish:clone().Parent = player.Inventory
end

guiAlert("Caught a "..fishName.."!", 3)
else
guiAlert("Nothing bit at all...", 3)
end
end
end
end

debouncing(1)
end



function shotLine(a, b, color)
local line = Instance.new("Part")
line.Anchored = true
line.CanCollide = false
line.formFactor = "Symmetric"
line.Size = Vector3.new(1, 1, 1)
line.BrickColor = BrickColor.new(color)

local distance = (b - a).magnitude
local position = (a + b) / 2

local mesh = Instance.new("BlockMesh")
mesh.Scale = Vector3.new(0.1, 0.1, distance)
mesh.Parent = line

line.CFrame = CFrame.new(position, a)
line.Parent = game.Workspace

game:GetService("Debris"):AddItem(line, 1)

delay(0, function()
for trans = 0, 1, 0.1 do
line.Transparency = trans
wait()
end

line:remove()
end)
end

function conditionStartup()
local condition = tool:findFirstChild("Condition")

if condition == nil then
condition = Instance.new("NumberValue")
condition.Name = "Condition"
condition.Value = getDurability()
condition.Parent = tool
end
end

function useGui(condition)
if condition == 0 then
return
end

local player, char = getPC()
local playerGui = player.PlayerGui

local textLabel = Instance.new("TextLabel")
textLabel.Name = "UseNotifier"
textLabel.TextColor3 = Color3.new(0, 0, 0)
textLabel.Text = condition
textLabel.Position = UDim2.new(0.5, 0, 0.4, 0)
textLabel.FontSize = "Size14"

if getType() == "Lighting" then
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.Position = UDim2.new(0.2, 0, 0.2, 0)
end

textLabel.Parent = playerGui.ScreenGui

delay(0.5, function() textLabel:TweenPosition(UDim2.new(0, 0, 1, 0)) wait(1) textLabel:remove() end)
end

function cleanGui()
local player, char = getPC()
local playerGui = player.PlayerGui
local screenGui = playerGui.ScreenGui
local guis = screenGui:GetChildren()

for index, child in pairs(guis) do
if child.Name == "UseNotifier" then
child:remove()
end
end
end

function removeLight()
local player, char = getPC()
local light = player:findFirstChild("Light")

if light ~= nil then
light:remove()
end
end

function use()
local condition = tool.Condition
condition.Value = condition.Value - 1

useGui(condition.Value)

if condition.Value <= 0 then
if getType() ~= "Ammunition" then
wait()

if getType() == "Lighting" then
removeLight()
end

cleanGui()
tool:remove()
end
end
end

function onMouseDown(mouse)
local type = getType()

if type == "Melee" then
meleeWeapon(mouse)
elseif type == "Blunt" then
bluntWeapon(mouse)
elseif type == "Pierce" then
pierceWeapon(mouse)
elseif type == "Ammunition" then
ammunitionWeapon(mouse)
elseif type == "Thrown" then
thrownWeapon(mouse)
elseif type == "Mining" then
miningTool(mouse)
elseif type == "Woodcutting" then
woodcuttingTool(mouse)
elseif type == "Threshing" then
threshingTool(mouse)
elseif type == "Skinning" then
skinningTool(mouse)
elseif type == "Fishing" then
fishingTool(mouse)
elseif type == "Lockpicking" then
lockpickingTool(mouse)
elseif type == "Lighting" then
lightingTool()
end
end

function onEquipped(mouse)
conditionStartup()

cleanGui()

mouse.Button1Down:connect(function()
onMouseDown(mouse)
end)
end

tool.Equipped:connect(onEquipped)
Report Abuse
SectionOne is not online. SectionOne
Joined: 12 Mar 2010
Total Posts: 3783
02 Nov 2015 03:16 PM
The F...
Report Abuse
SwagCuzYolo is not online. SwagCuzYolo
Joined: 31 Oct 2013
Total Posts: 1224
02 Nov 2015 03:42 PM
Damn
Report Abuse
SectionOne is not online. SectionOne
Joined: 12 Mar 2010
Total Posts: 3783
02 Nov 2015 03:46 PM
This script seems longer than my database script...
Report Abuse
SwagCuzYolo is not online. SwagCuzYolo
Joined: 31 Oct 2013
Total Posts: 1224
02 Nov 2015 03:51 PM
^ I would hope so, rip
Report Abuse
Jalandrian is not online. Jalandrian
Joined: 23 Mar 2012
Total Posts: 3581
02 Nov 2015 03:57 PM
lol
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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