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

attempt to index nil with 'Character'?

Asked by 3 years ago

Im confused about what went wrong. Its a workspace script.

-- GetService
local proximityprompt = game:GetService("ProximityPromptService")
local inputservice = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local ps = game:GetService("Players")

-- Other Variables
local player = game.Players.LocalPlayer.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local openpc = script.Parent
local typingpc = script.Parent.Parent.typingpc
local holdDuration = typingpc.HoldDuration
local animation1 = 'http://www.roblox.com/asset/?id=6399052845'
local animation2 = 'http://www.roblox.com/asset/?id=6406983765'
local anim = Instance.new("Animation")
local randomNumber = math.random(5,25)
local progressbar = game.StarterGui.SurfaceGui.Screen.Bar.Progress
local screen = game.StarterGui.SurfaceGui.Screen
randomNumber = holdDuration
0
Is It a serverscript or a localscript? Punctist 120 — 3y
0
server script krxtenaa 11 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

game.Players.LocalPlayer cannot be used in a server script and will be nil, as there is no local player on the server. The code you've provided will only work in a local script.

0
Exactly. Punctist 120 — 3y
Ad

Answer this question