Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to index nil with 'Character'?

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

2 comments

0

Is It a serverscript or a localscript?

0

server script

1 answer

✓ Accepted answer

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.

1 comment

0

Exactly.

This discussion is preserved as it was. New answers, comments, and votes are closed.