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

why is my printing, chatlogs script not working as i intended?

Asked by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
function onChatted(msg, recipient, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
    if msg then
        print(speaker.Name.. msg)
    end
end

function onPlayerEntered(Player) 

    Player.Chatted:Connect(function(msg, recipient)
        onChatted(msg, recipient, Player)
    end)
end

onPlayerEntered()

The script will go like this: First, the Player will talk. Second, it should print the username and the message. Example: raid6n: Can you be my friend?

The script doesn't work with an output of: 18:07:59.288 - ServerScriptService.Script:11: attempt to index local 'Player' (a nil value)

I don't know why it doesnt work as I defined what "Player" is in line 9

I'm not good at this, so please send an answer if you can. This is a regular script.

2 answers

Log in to vote
1
Answered by 4 years ago

thats hard maybe a local script and use local Player = game.Players.LocalPlayer it maybe work try putting at line 10

1
I’ll see what happens. raid6n 2196 — 4y
0
ok btw thanks for helping with my other questions ur a great friend ProbablyRiley 0 — 4y
1
no problem also it works now thanks raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
View all comments (34 more)
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
1
have a great day raid6n 2196 — 4y
0
bruh ProbablyRiley 0 — 4y
1
big lag SoftlockedUnderZero 668 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
oop sorry raid6n 2196 — 4y
1
Jesus crist- raid6n 2196 — 4y
1
Jesus crist- raid6n 2196 — 4y
0
stack overflow moment SoftlockedUnderZero 668 — 4y
0
lmao ProbablyRiley 0 — 4y
Ad
Log in to vote
2
Answered by 4 years ago

Line 16. If you don't a value in an argument of an executed function, it will default to nil.

Here's an example.

local function A_1(b)
    if a==nil then
        print('argument "b" is nil')-- printed
    end
end;

A_1()
0
yeah i think that would work ProbablyRiley 0 — 4y
0
yeah i think that would work ProbablyRiley 0 — 4y

Answer this question