i tried this and everything seems ok but nothing works?
01 | local Players = game:GetService( "Players" ) |
02 | local player = Players.LocalPlayer |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 |
05 | script.Parent.Touched:Connect( function (h) |
06 | local hum = h.Parent:FindFirstChild( "Humanoid" ) |
07 | if hum ~ = nil then |
08 | if player.MembershipType = = Enum.MembershipType.Premium then |
09 |
10 | script.Parent.CanCollide = false |
11 | wait( 0.1 ) |
12 | script.Parent.CanCollide = true |
13 |
14 | else |
15 | -- prompt premium purchase |
Since this isn't a LocalScript, Players.LocalPlayer won't work, as this method only works in a LocalScript. (If this is a LocalScript, the script won't run at all if it's in Workspace)
To find the player, you can use Players:GetPlayerFromCharacter()
Example:
1 | script.Parent.Touched:Connect( function (part) |
2 | local humanoid = part.Parent:FindFirstChild( "Humanoid" ) |
3 | if (humanoid ~ = nil ) then |
4 | player = game:GetService( "Players" ):GetPlayerFromCharacter(humanoid.Parent) |
5 | end |
6 | end ) |