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: Local script issues- again xD

Previous Thread :: Next Thread 
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
29 Jul 2011 02:14 PM
These things never fail to mess up.

Today I have written a 137 line raycasting gun script for a hopperbin. I am getting beautiful functionality and printed output in Play Solo, and I am getting absolutley no ouput what soever on a Test Server.

*I AM NOT GETTING OUTPUT WHEN IT DOESN"T WORK, DON"T ASK ME TO POST OUTPUT PLEASE.*

Here is the script, the function names are rather explanatory- maybe except 'bolt'. That function creates a brick on a ray and is not important.

Bin = script.Parent
Player = Bin.Parent.Parent
print("Running " ..Bin.Name)

function load_vars(r, t, s, a, dshiftfrom, dshiftto, trc, sd, mmc, mmt)
print("Declaring Stats ", r, t, s, a, dshiftfrom, dshiftto, trc, sd)
--[[Player Vairables]]
Bin = script.Parent
Player = Bin.Parent.Parent
--[[Object Variables]]
charge = Bin.Charge.Value
heat = Bin.Heat.Value
clipCapacity = Bin["Clip Capacity"].Value
clips = Bin.Clips.ConstrainedValue
--[[Local Variables]]
fcount = 0
tcount = trc
range = r
translate = t
selected = s
laccuracy = a
damage = 50
damage_shift = Vector2.new(dshiftfrom, dshiftto)
selection_distance = sd
mmcount = mmc
mmtag = mmt
--[[Brick Objects]]
if select_indicate then select_indicate:Remove() end
select_indicate = Instance.new("Part")
select_indicate.formFactor = "Symmetric"
select_indicate.Size = Vector3.new(1, 1, 1)
select_indicate.Transparency = .7
m = Instance.new("CylinderMesh")
m.Scale = Vector3.new(6, 7, 6)
m.Parent = select_indicate
end
load_vars(200, 4, false, 3, -20, 40, 3, 20, 0, 5)

function bolt_create(boltframe, distance)
local distance = distance or range
b = Instance.new("Part")
b.BrickColor = BrickColor.new("New Yeller")
b.formFactor = "Custom"
b.Size = Vector3.new(.2, distance, .2)
b.CFrame = boltframe*CFrame.new(0, 0, -((distance/2)-translate))
b.Parent = game.Workspace
wait(.1)
b:Remove()
b = nil
end

function create_ray(Origin, Part, x_shift, y_shift, distance)
print("Creating Ray from" .. origin .. " to " ..Part.Position)
distance = distance or range
x_shift = x_shift or accuracy*(distance/10)
y_shift = y_shift or accuracy*(distance/10)
xs = math.random(-x_shift, x_shift)
ys = math.random(-y_shift, y_shift)
r = Ray.new(Origin, (Part.Position - Origin) + Vector3.new(xs, ys, 0))
p, endP = game.Workspace:FindPartOnRay(r)
return r, p, xs, ys, distance, endP
end

function Fire()
print("Fire!")
if selected then
fcount = fcount + 1
cast, p, shifted_x, shifted_y, leangth, endP = create_ray((Plyr.Character.Torso.CFrame*CFrame.new(0, 0, -translate)).p, selected.Torso)
if p then
if p.Parent:findFirstChild("Humanoid") then
p.Parent:findFirstChild("Humanoid").Health = p.Parent:findFirstChild("Humanoid").Health - (damage + math.random(damage_shift.x, damage_shift.y))
end
else print("No intersect")
end
if fcount >= tcount then
fcount = tcount
bolt(
( CFrame.new(Player.Character.Torso.CFrame * CFrame.new(0, 0, -translate).p, selected.Torso.Position)),

( CFrame.new((Plyr.Character.Torso.CFrame*CFrame.new(0, 0, -translate)).p-endP).magnitude)
)
end
else print("No selection")
end
end

function find_Player(position, d)
print("Finding Players...")
local dist = d or selection_distance
p = game.Players:GetChildren()
local select
for i=1, #p do
if (p[i].Character.Torso.Position-position).magnitude < dist then
--if p[i].TeamColor ~= Player.TeamColor then
select = p[i].Character
tc = p[i].TeamColor
dist = (p[i].Character.Torso.Position-position).magnitude
--end
end
end
if select then
print("Player Found!")
select_indicate.Parent = workspace.CurrentCamera
select_indicate.BrickColor = tc
if select_indicate:findFirstChild("Weld") then
select_indicate:findFirstChild("Weld"):Remove()
end
w = Instance.new("Weld")
w.Parent = select_indicate
w.Part0 = select_indicate
w.Part1 = select.Torso
w.C0 = CFrame.new(0, 0, 0)
return select, dist
end
end

function click(mouse)
print("OMG U CLICKEDED!")
selected, match = find_Player(mouse.Hit.p)
Fire()
end

function move(mouse)
mmc = mmc + 1
if mmc >= mmt then
mmc = 0
print("mouse move")
selected, match = find_Player(mouse.Hit.p)
end
end

function BinSelected(mouse)
print("Welcome...warming up")
clickconnect = mouse.Button1Down:connect(function() click(mouse) end)
moveconnect = mouse.Move:connect(function() move(mouse) end)
end
Bin.Selected:connect(BinSelected)
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
29 Jul 2011 02:41 PM
There are plenty of erros in this script that are comming up in solo mode- but I still don't have ANY output in servers? Anyone know why?
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
29 Jul 2011 02:42 PM
Too much writing.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
29 Jul 2011 02:44 PM
At first I was like "la la *whistles*" but then I read this and I was like "Ow my head hurts"
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
29 Jul 2011 02:46 PM
Ok hows this:

local scriptin hopperbin!

print("OMG I'm making output!")

in Solo mode output reads:
>OMG I'm mkaing output!
>You has a bunch of erros dude, fix these things:
>lists all my mistakes

on a test server, out put reads:
>

...


(That was nothing)


Get the idea?
Report Abuse
Mathman314 is not online. Mathman314
Joined: 31 Jul 2009
Total Posts: 556
29 Jul 2011 02:50 PM
Hmmm, I'm not sure... I usually just stay on Solo mode...

But my local scripts are messed up too... They don't seem to work with 2+ people on a server :/
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
29 Jul 2011 02:53 PM
..I might have fixed it...


becuse the servers and the local enviroments are not always 100% in sinc, local scripts have a tendancy to start running before they 'exist'. I need to add a wait() infront of the script to solve that.

I do that with all my local scripts- just forgot on this one x(
Report Abuse
Mathman314 is not online. Mathman314
Joined: 31 Jul 2009
Total Posts: 556
29 Jul 2011 02:55 PM
Oh right :P

Wait()

should work...
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
29 Jul 2011 03:00 PM
IT WORKS! THANKS GUYS! =D
Report Abuse
asimo3089 is not online. asimo3089
Joined: 19 Apr 2009
Total Posts: 1184
29 Jul 2011 03:01 PM
Considering a large amount of us are narbs compared to what you can do...Id post that in the scripters forum, another forum section at the bottom of the main forum page...They seem to be more helpful on this stuff usually ;D
Report Abuse
asimo3089 is not online. asimo3089
Joined: 19 Apr 2009
Total Posts: 1184
29 Jul 2011 03:02 PM
spoke a minute too soon dangit xD
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