Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] How to use Object as String?

Asked by 4 years ago
Edited 4 years ago
01mouse.Button1Down:Connect(function()
02    if mouse.Target.Parent:FindFirstChild("Humanoid") then
03        local arrestee = mouse.Target.Parent
04        print(arrestee)
05        local arrested = game.Players[arrestee]
06        if arrested["TeamColor"] == BrickColor.new("Teal") or arrested["Settings"].innocent.Value == true then
07            print("innocent")
08        else
09            game.ReplicatedStorage.Arrest:FireServer(arrestee)
10        end
11    end
12end)

I am trying to us arrestee as a string, anyway to do that?

Edit: I solved the issue by putting the team checker part to a script:

1if mouse.Target.Parent:FindFirstChild("Humanoid") then
2        local arrestee = mouse.Target.Parent
3        print(arrestee)
4        game.ReplicatedStorage.Arrest:FireServer(arrestee)

1 answer

Log in to vote
0
Answered by 4 years ago

you would use .Name

01mouse.Button1Down:Connect(function()
02    if mouse.Target.Parent:FindFirstChild("Humanoid") then
03        local arrestee = mouse.Target.Parent
04        print(arrestee.Name)
05        local arrested = game.Players[arrestee.Name]
06        if arrested["TeamColor"] == BrickColor.new("Teal") or arrested["Settings"].innocent.Value == true then
07            print("innocent")
08        else
09            game.ReplicatedStorage.Arrest:FireServer(arrestee)
10        end
11    end
12end)
0
It didnt work BabanizPROcuk 49 — 4y
0
What error did you get? PureLiteStudio 80 — 4y
0
Unable to cast value to object BabanizPROcuk 49 — 4y
0
What line? PureLiteStudio 80 — 4y
View all comments (2 more)
0
Still gonna accept your answer since it solved the problem on my other script and you are the only one helped BabanizPROcuk 49 — 4y
0
5th line and 6th line BabanizPROcuk 49 — 4y
Ad

Answer this question