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

How do i detect a player that stepped on a certain part?

I need a script to log the players name if they've stepped on a 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"

1 comment

0

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

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