Hi devs,
For some reason I can’t rename a string value.
I have this script here:
local weaponType = Instance.new("StringValue")
weaponType.Parent = humanoid.Parent
weaponType.Name = "WeaponType"
weaponType.Value = "ClassicSword"
It will create a StringValue and change it’s Parent and Value, but it won’t change it’s name.
Can anyone help with this?
It works perfectly fine in other scripts
Its working on me, how do u know and check that it wont change the Name?
It adds the value to a player when they’re damaged, and the name is “Value” so it just adds lots of them
And when you run it the Name will be not changed?
Nope
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
Inf_idel
(Infidel)
July 31, 2022, 12:39am
6
Are you running this on the client or server, and are you viewing on the server or client
Viewing on client and running on server
The script what u made is it inside the Client or Server?
Inf_idel
(Infidel)
July 31, 2022, 12:41am
9
Try moving the parent line under the rest of the code.
Such as
local weaponType = Instance.new("StringValue")
weaponType.Name = "WeaponType"
weaponType.Value = "ClassicSword"
weaponType.Parent = humanoid.Parent
It’s inside a serverscript.
I also have a similar value called PlayerThatDamaged which works fine right next to it
This is the full part of that area:
if humanoid.Parent:FindFirstChild("WeaponType") then
humanoid.Parent:WaitForChild("WeaponType").Value = "ClassicSword"
else
local weaponType = Instance.new("StringValue")
weaponType.Parent = humanoid.Parent
weaponType.Name = "WeaponType"
weaponType.Value = "ClassicSword"
end
Inf_idel
(Infidel)
July 31, 2022, 12:44am
13
You already used :FindFirstChild theres no reason for you to be using :WaitForChild here, Also when using a :WaitForChild argument I advise you use a timeout value such as 5-10
This could be causing the script to yield waiting for a new child to be added named WeaponType
Pegagittt
(Pegagit)
July 31, 2022, 12:46am
14
I thing the Problem is, the Value will not be going inside the Humanoid because, u dont need the Parent at the end, do this instead:
weaponType.Parent = humanoid
Try if this will work
Pegagittt
(Pegagit)
July 31, 2022, 12:47am
15
It would not yield, because WaitForChild will also run, if there is already a WeaponType
Inf_idel
(Infidel)
July 31, 2022, 12:47am
16
He’s not trying to parent to the humanoid, he’s trying to parent to the humanoids parent. This line is fine
1 Like
Inf_idel
(Infidel)
July 31, 2022, 12:48am
17
This could cause a memory leak. There is no reason to use :WaitForChild after you already used :FindFirstChild on the same object
I’m trying to put it inside that character, rather than the humanoid.
The reason I’m using humanoid.Parent is that I’m modifying a script made by someone else that uses humanoid rather than the character.
Pegagittt
(Pegagit)
July 31, 2022, 12:49am
19
Do you test it, that this can happen?
Maybe try changing the name before you reparent it? it looks like it should work.