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: Table and mesh help.

Previous Thread :: Next Thread 
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 04:32 PM
I'm new to tables so I'm not sure what I did wrong but my script down below isn't working correctly, It is however checking the leaderstat value for a change and printing the notification print to let me know it does detect the change..

However, when the value changes to "9mm Pistol" or "Assault Rifle" the handle's meshId/TextureId doesn't change, nor is their any output errors..

Please help.

Script :

--I do have everything definded, if its not deifined here it IS defined in the rest of the script thats not posted.
Tool = script.Parent
local Handle = Tool.Handle
function Hmesh(mesh,text)
Handle.Mesh.MeshId = mesh
Handle.Mesh.TextureId = text
end
function
local CurrentGun = game.Players.LocalPlayer.leaderstats:findFirstChild("CurrentGun")
Guns = {"9mm Pistol" , "Assault Rifle"}
CurrentGun.Changed:connect(function()
print("CurrentGun has changed")
if CurrentGun == Guns[1] then
print(player.."Is using 9mm Pistol")
Hmesh("http://www.roblox.com/asset/?id=72012879","http://www.roblox.com/asset/?id=72012859") -- mesh then texture
elseif CurrentGun == Guns[2] then
print(player.."Is using Assault Rifle")
Hmesh("http://www.roblox.com/asset/?id=72012671","http://www.roblox.com/asset/?id=72012605") -- mesh then texture
end
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 04:57 PM
bump
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 05:04 PM
2bump2
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 05:13 PM
3bump3
Report Abuse
Frostglacier is not online. Frostglacier
Joined: 28 Oct 2010
Total Posts: 4177
08 Jun 2013 05:14 PM
Could you explain why you repeat the meshes twice?
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 05:22 PM
One's a mesh other is a texture, I shall indeed explain .

In the function "Hmesh" it has 2 values, one is named "mesh" and the other is "text"
"mesh" is for the Meshes "MeshId", and "text" is for the Meshes "TextureId".

The reason why you see two "meshes" even though one is a mess and the other is a texture, is because in the following snippet it requires you to give a value for the MeshId and the TextureId.

function Hmesh(mesh,text)
Handle.Mesh.MeshId = mesh
Handle.Mesh.TextureId = text
end

I call the meshId/TextureId by saying : Hmesh("meshidgoeshere","textureidgoeshere")

Making it easier for me to just copy&paste the assetId over the existing ones instead of having to type out the old fashion way.

Follow?
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 05:30 PM
/\
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 05:45 PM
bump
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Jun 2013 06:06 PM
Maybe try CurrentGun.Name?
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 06:12 PM
That won't help.. This is for a hopperbin tool..
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 06:24 PM
If the whole script is needed.. here :

--Lots of notes, this was my first weapon script.. Gone through much edditing.
--[[
ClipAmmo is how much ammo the current clip can have, once it reaches 0 it needs to reload.
TotalAmmo is a leaderstat value of how much ammo you have in total for this type of ammo, its also a leaderstat value for DP.
ReloadSpeed is the speed for how fast the player will reload the gun.
--]]
repeat wait(0) until game.Players.LocalPlayer:FindFirstChild("leaderstats")
Tool = script.Parent
player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character
local mouse = player:GetMouse()
local camera = Workspace.CurrentCamera
local user
-----------------
local Handle = Tool.Handle
function Hmesh(mesh,text)
Handle.Mesh.MeshId = mesh
Handle.Mesh.TextureId = text
end
function weld(ob0,ob1,parent,c1)
w = Instance.new("Weld",parent)
w.Part0 = ob0
w.Part1 = ob1
w.C1 = w.C1 * c1
end
local NewS = script.Parent.AmmoGui:Clone()
NewS.AmmoHud.Visible = true
NewS.Parent = player.PlayerGui
-----------------
GunTable = {"9mm Pistol" , "Assault Rifle"}
-----------------
local CurrentGun = game.Players.LocalPlayer.leaderstats:findFirstChild("CurrentGun")
local ClipAmmo = Tool.ClipAmmo
local TotalAmmo = game.Players.LocalPlayer.leaderstats.Ammo9mm
local ReloadSpeed = Tool.ReloadSpeed.Value
local GunSkill = game.Players.LocalPlayer.leaderstats:findFirstChild("GunSkill").Value
local firing = false
local equipped = false
-----------------------------
local DefaultDamage=7
local gunskill= GunSkill

local BulletDamage=DefaultDamage * gunskill / 10
damage = BulletDamage

----------------------------- You can edit down below to your likings.
function reload()
firing = true
--this is a snippet I'll have the stuff defined latorz.
if ClipAmmo.Value <= 1 then
TotalAmmo.Value = TotalAmmo.Value - 30 + ClipAmmo.Value
ClipAmmo.Value = 30
wait(ReloadSpeed)
firing = false
end
end
-------------------------------------------------------------------------
function fire(v)

if ClipAmmo.Value < 1 and TotalAmmo.Value < 1 then return end -- stops the function

if ClipAmmo.Value >= 1 and equipped == true and firing == false then
elseif ClipAmmo.Value <= 1 then
firing = true
reload()
end
Handle.Fire:play() --This plays the sound thats in the Part named "Handle" in the tool.
ClipAmmo.Value = ClipAmmo.Value -1
local vCharacter = player.Character
local vPlayer = game.Players:playerFromCharacter(vCharacter)

-----------------------------[ THE BULLET!]-----------------------------
local ray = Ray.new(Handle.CFrame.p, (mouse.Hit.p - Handle.CFrame.p).unit*50)
local hit, position = game.Workspace:FindPartOnRay(ray, user)
--If I should want to cause damage to the humanoid, add it here on this line.
--draw the ray
local distance = (position - Handle.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright yellow")
rayPart.Transparency = 0
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
rayPart.Parent = game.Workspace
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(damage)
print(damage)
end -- ending
game.Debris:AddItem(rayPart, 0.1)
end
--end
--Equipped
Tool.Selected:connect(function(mouse)
NewS.Parent = player.PlayerGui
Tool.GunSkill.Value = GunSkill
Handle.Parent = game.Workspace
equipped = true
weld(player.Character["Right Arm"],Handle,player.Character["Right Arm"],CFrame.new(0,-1.5,0) * CFrame.fromEulerAnglesXYZ(math.rad(180),0,0) )
print("Equiped")
end)

Tool.Deselected:connect(function(mouse)
NewS.Parent = nil
equipped = false
--NewS:Destroy() --This part is wrong, but I don't know what else to put in.
print("Un-Equiped")
end)

mouse.Button1Down:connect(function()
if not Tool.Active then
return
end

Tool.Active = true

local character = player.Character;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end

local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit

fire(lookAt)

wait(.5)

Tool.Active = true
end)

ClipAmmo.Changed:connect(function()
local GUI = player.PlayerGui.AmmoGui
if GUI ~= nil then
GUI.AmmoHud.ClipAmmo.Text = ""..ClipAmmo.Value
GUI.AmmoHud.TotalAmmo.Text = ""..TotalAmmo.Value
end
end)

CurrentGun.Changed:connect(function()
print("CurrentGun has changed")
if CurrentGun == GunTable[1] then
print(player.."Is using 9mm Pistol")
Hmesh("http://www.roblox.com/asset/?id=72012879","http://www.roblox.com/asset/?id=72012859") -- mesh then texture
elseif CurrentGun == GunTable[2] then
print(player.."Is using Assault Rifle")
Hmesh("http://www.roblox.com/asset/?id=72012671","http://www.roblox.com/asset/?id=72012605") -- mesh then texture
end

end)
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 07:15 PM
/\
le me need ze help.
Report Abuse
btft is not online. btft
Joined: 19 Feb 2011
Total Posts: 1512
08 Jun 2013 07:17 PM
function Hmesh(mesh,text)
Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id="..mesh
Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id="..text
end

Hmesh(123456, 103967")
Report Abuse
btft is not online. btft
Joined: 19 Feb 2011
Total Posts: 1512
08 Jun 2013 07:18 PM
Hmesh(123456, 103967)

Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 07:47 PM
Thanks.. still have the same problem as before though.. the script ignore's the table checking.
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 07:58 PM
/\
Report Abuse
btft is not online. btft
Joined: 19 Feb 2011
Total Posts: 1512
08 Jun 2013 08:09 PM
Can you please dissect the section and post the table checking section? So I can 'debug' it.

btw tl;dr.
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 08:13 PM
CurrentGun.Changed:connect(function()
print("CurrentGun has changed")
if CurrentGun == GunTable[1] then
print(player.."Is using 9mm Pistol")
Hmesh(72012879,72012859) -- mesh then texture
elseif CurrentGun == GunTable[2] then
print(player.."Is using Assault Rifle")
Hmesh(72012671,72012605) -- mesh then texture
end
end)

There
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 08:32 PM
bumped
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 08:41 PM
:l
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 08:46 PM
...
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Jun 2013 08:48 PM
Just don't use a table, XD.
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 08:51 PM
Then what am I suppose to use? :/
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Jun 2013 10:03 PM
If statement..? If CurrentGun == "Assault thing" then
Report Abuse
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
08 Jun 2013 10:29 PM
Well that works.. just needed to add a .Value..

...

DERP.

fixed.
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