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

What did I do wrong in the script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
wait(10)
Plrs = game.Players:GetPlayers()
infected = Plrs[math.random(1,#Plrs)]
print(#Plrs)
print(infected)
local ScriptClone = game.ServerScriptService.Script1:clone() --Clones it
ScriptClone.Parent = game.Workspace(infected).Torso --Moves the script to the player
ScriptClone.Disabled = false --Allows the script to execute

Whenever it runs it says 15:13:54.870 - Workspace.Variablesssss:7: attempt to call field 'Workspace' (a userdata value)

I cant figure out whats wrong.

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

The game thinks you're trying to run a function because you had parentheses closing off the word 'Workspace'. You need to get the player a different way anyways to avoid confusion with other objects. To do that, we'll use the player's property, 'Character'.


We simply need to edit your script, and fix that line:

wait(10)
Plrs = game.Players:GetPlayers()
infected = Plrs[math.random(1,#Plrs)]
print(#Plrs)
print(infected)
local ScriptClone = game.ServerScriptService.Script1:clone() --Clones it
ScriptClone.Parent = infected.Character.Torso --Moves the script to the player
ScriptClone.Disabled = false --Allows the script to execute

And there you go. It's as simple as that :P


If you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P

-Dyler3

Ad

Answer this question