I need a script to log the players name if they've stepped on a part.
✓ ANSWER ACCEPTED
How do i detect a player that stepped on a certain part?
1 answer
✓ Accepted answer
This can be done by using this code
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local part = <Put part identifier here>
part.Touched:Connect(function(hit)
if hit ~= nil then
local PlayerName = hit:GetFullName()
local StringValue = Instance.new("StringValue")
StringValue.Parent = <StringValue's parent>
StringValue.Value = tostring(PlayerName)
end)
Here, it has also created a string value so that it can be stored in DataStore, ReplicatedStorage, or any other place. To make identification of the StringValue easier, assign it a unique name like:
StringValue.Name = tostring(PlayerName).."_StringValue"
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks, you might wanna edit your code and add another "end" before the function ends for anyone else trying to use this code