Okay so I have a string value and the value inside of it is like a name, and what I want to do with is make it so if a player says something in the chat for example a spell and put the value name;
spell name, [value]
I need the script to player the value belongs to when they put the name of the value instead of the player’s name. I’ve already tried to do this but failed, I need to find the previous script I used because I got rid of it since it didn’t work but any help would be appreciated.
Do you mean the value is the player whom you’re targeting?
You can use this method:
local Player = game:GetService("Players"):FindFirstChild(value) -- Find player by full name
or
local target = nil
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if value:lower() == player.Name:lower():sub(1, #value) then -- Used to cut player names to the length of the value
target = player
break
end
end
-- This will find a player even if you didn't type their full name
local target = nil
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if value:lower() == player.Name:lower():sub(1, #value) then -- Used to cut player names to the length of the value
target = player
break
end
end
-- This will find a player even if you didn't type their full name
I made my message confusing but let me explain it fully, okay so there is a value named “Name” and the value of that is the character’s name (e.g; Amara) right. So if a player was casting a spell (it’s remote so they can either put the player’s name or the character’s name for it to work). If they put the character’s name (the value inside of the Name value) then it should be the same as if you put the player’s name but the thing is when I tried that it did not work so how would I go about doing that with no errprs.
Well, either way, you can just use the player name and get their character from the Player instance.
The player instance has a Character property to obtain their current character.
function obtainPlayer(name)
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if value:lower() == player.Name:lower() then
return player
end
end
end
local target = obtainPlayer("Amara") -- Gets the player
local character = target.Character -- Gets their character
Well yeah but like there’s a selection system in place which spawns them as a different model with a folder named Information and it contains a value for the character name within that folder as seen below;
And the value inside of CharacterName is the character’s name “Amara” so basically when the player say’s in the chat;
Attenuare, (charactername.value)
It need’s to fire the spell to the player that the folder/value is found inside of.
I’m not sure if you mean the characters move, because Player.Character is an ObjectValue which doesn’t care if the object moves it’ll always have it as a value.
And I’m sure it might work, if it doesn’t we can always figure out a different method to run it.
Okay I’ll try if your method work’s, also the attenuare thing is basically like an incantation and there’s already an system in place that handles when the player says it in the chat but the thing is I just need it to fire to the player still if the character’s name is put. What I mean by the character’s name is the value inside of the CharacterName StringValue.
Also I know this is off-topic but is this bug happening to you as well, when you collapse something it keeps re-opening everytime when you click something else?