letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 07:23 PM |
so i have a script that checks inside a tool for a stringvalue called "GunType". now guntype is clearly in the tool, but the script always posts the error "GunType is not a valid member of Tool" anyone know why?
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 07:24 PM |
it gets cloned from serverstorage btw. it works the first time. not the second time
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 07:24 PM |
| GunType is not an actual part of roblox lua scripting. Unless you created a variable before in the script GunType does nothing atm which is why it says "GunType is not a valid member of Tool" If you want me to give you the script for what you want "GunType" to do then tell me. |
|
|
| Report Abuse |
|
|
Dratik
|
  |
| Joined: 13 Nov 2008 |
| Total Posts: 36385 |
|
|
| 10 Nov 2017 07:31 PM |
Explain a little bit more on what you mean by it works the first time, but not the second time? Like do you have to purchase the gun, or what?
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 07:33 PM |
so what happens is the player spawns into a map each round and has the gun cloned from serverstorage to the backpack. then nothing works after the first round.
code: local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character.Humanoid local Chr = Player.Character local Humanoid = Chr.Humanoid local Frame = script.Parent local Tools = Player.Backpack:GetChildren() local Module = require(script.Parent.ModuleScript)
local UserInput = game:GetService("UserInputService")
local GunEquipped = script.Parent.GunEquipped
--- Bool Values local IsPrimaryEquipped = false local IsSecondaryEquipped = false local IsGadget1Equipped = false local IsGadget2Equipped = false local IsWriting = script.Parent.Parent.Parent.ChatGui.IsWriting
UserInput.InputBegan:connect(function(Input) -- Primary if Input.KeyCode == Enum.KeyCode.One then print("clicked") if not IsWriting.Value then if Humanoid.Health > 0 then GunEquipped.Value = 'Primary' for i,v in pairs (Tools) do while not v.GunType do print('no guntype') wait() end if v.GunType.Value == 'Primary' then Humanoid:EquipTool(v) break end spawn(function() Module(Frame) end) end end end -much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 07:34 PM |
have you tried making a while loop to constantly put a new "GunType" value?
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 07:36 PM |
| okey dokey, too much for me, all i can say is make a while loop and for one of the "local"s you put GunEquipped in the same exact local that made it. |
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 07:38 PM |
^huh?
the value is already in the tool, no script adds the "GunType" in the tool
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 07:39 PM |
| I didn't know GunType was an actual variable |
|
|
| Report Abuse |
|
|
Dratik
|
  |
| Joined: 13 Nov 2008 |
| Total Posts: 36385 |
|
|
| 10 Nov 2017 07:47 PM |
Don't ask my why, but I feel like the issue lies somewhere in here:
for i,v in pairs (Tools) do while not v.GunType do print('no guntype') wait() end if v.GunType.Value == 'Primary' then Humanoid:EquipTool(v) break end
Maybe instead of using a while not v.GunType loop, just use a if v.GunType == nil statement instead? Because it's already looping through all of the tools.
|
|
|
| Report Abuse |
|
|
Dratik
|
  |
| Joined: 13 Nov 2008 |
| Total Posts: 36385 |
|
|
| 10 Nov 2017 07:48 PM |
I highly doubt that will make any difference because it doesn't seem directly linked with the issue, but I just can't see anywhere else that it would be messing up on.
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:09 PM |
I found the issue, or AN issue. if v.GunType.Value == 'Primary' then, the problem being that you don't actually check if the GunType exists in the first place inside of the weapon which gives you the error because, for whatever reason, it actually doesn't exist inside the weapon.
To fix this, all we have to do is check if the GunType is null or not and replace "while not v.GunType do print('no guntype') wait() end" with the new line of code.
q = v:FindFirstChild("GunType") if q then Humanoid:EquipTool(v) else print('no guntype') end
This will make it functional however if it prints 'no guntype' that means there is actually no stringvalue inside of the tool. |
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:18 PM |
would having the gun cloned from serverstorage into the players backpack for the second time have anything with making it break?
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:21 PM |
| I don't think it would. I'd have to take a look at the script that copies it over, if you're willing to reveal it. |
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:24 PM |
| i can show this much, and this whole thing fires every round local m4 = game.ReplicatedStorage.Guns.M4:Clone() if not ServerBools.MatchEnded.Value then player:ClearCharacterAppearance ( ) local shirt = Instance.new("Shirt") shirt.Parent = player.Character local pants = Instance.new("Pants") pants.Parent = player.Character if class == "shadow" then shirt.ShirtTemplate = "rbxassetid://695415585" pants.PantsTemplate = "rbxassetid://754894615" player.Character.Humanoid:AddAccessory(goggles) player.Character.Humanoid:AddAccessory(mask) player.Character.Humanoid.WalkSpeed = 17 player.Character.Humanoid.MaxHealth = 70 plrGui.HUD.HealthBar.HealthBar.TextLabel.Text = #### ######### = player.Backpack -much to learn, you still have |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:32 PM |
So does the gun get copied over the second time you try it?
Also did you try it with my code? Here's a compiled version of the first script you provided with my code implemented, if you already didn't try it out.
local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character.Humanoid local Chr = Player.Character local Humanoid = Chr.Humanoid local Frame = script.Parent local Tools = Player.Backpack:GetChildren() local Module = require(script.Parent.ModuleScript)
local UserInput = game:GetService("UserInputService")
local GunEquipped = script.Parent.GunEquipped
--- Bool Values local IsPrimaryEquipped = false local IsSecondaryEquipped = false local IsGadget1Equipped = false local IsGadget2Equipped = false local IsWriting = script.Parent.Parent.Parent.ChatGui.IsWriting
UserInput.InputBegan:connect(function(Input) -- Primary if Input.KeyCode == Enum.KeyCode.One then print("clicked") if not IsWriting.Value then if Humanoid.Health > 0 then GunEquipped.Value = 'Primary' for i,v in pairs (Tools) do q = v:FindFirstChild("GunType") if q then Humanoid:EquipTool(v) else print('no guntype') end spawn(function() Module(Frame) end) end end end
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:32 PM |
its suppose to say m4 . Parent where the tags are
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:34 PM |
and yes it clones into the backpack the second time, and the "GunType" is very quite clearly in the tool. and i have tried your code implemented. and it just prints out the no guntype ,_,
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:41 PM |
also this is a bit out of context, but can a server script access a clients Gui's?
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:42 PM |
| Is the stringvalue INSIDE of any object that is INSIDE of the tool? |
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:44 PM |
nope, the stringvalue's parent is the tool.
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:44 PM |
| If Filtering Enabled is turned on then a server script can't access a client's gui UNLESS you use remote events. |
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:47 PM |
welp i knew it would come to this ._. when i go into a test server nothing with the guns being equipped works. not even the first time
-much to learn, you still have
|
|
|
| Report Abuse |
|
|
letris
|
  |
| Joined: 17 Dec 2012 |
| Total Posts: 572 |
|
|
| 10 Nov 2017 08:54 PM |
well i seemed to fix it, it now works, except for when the player respawns from dying ,_, slowly figuring this out, but thanks for the help doods
-much to learn, you still have
|
|
|
| Report Abuse |
|
|