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

Easy script is not working in roblox player, can you help me or tell me other way to do it?

Asked by 6 years ago
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
           -- any script you put here will work in studio but not in player
        end
end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Hello SuperBeeperman, you can use this.

script.Parent.Touched:Connect(function(hit)
       local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Returns the Player associated with the given character, or nil if the character is not controlled by a player.
       if Player then
             print(Player.Name)
             --  ur script here
       end
end)
Ad

Answer this question