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

How to make a gamepass to give a sword when hit a part?

Asked by 4 years ago

code is this


local id = 7746555 local MarketPlaceService = game:WaitForChild:FindFirstChild("MarketplaceService") local Players = game:("Players") local Sword = game.ServerStorage.Sword local debounce = true local part = script.Parent local function onTouched(part) local player = Players:GetPlayerFromChar(part.Parent.) if not player then return end if debounce == true then if MarketPlaceService:UserOwnerOfGamePass(UserId id) then local backpack = player.Backpack debounce = false Sword:Clone(1).Parent = backpack wait (1) debounce = true end end end part.Touched:Connect(onTouched) == true

1 answer

Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago

Old script:


local id = 7746555 local MarketPlaceService = game:WaitForChild:FindFirstChild("MarketplaceService") -- This is incorrect, It’s suppose to be game:GetService("MarketplaceService"). also, never use findfirstchild after wait for child local Players = game:("Players") local Sword = game.ServerStorage.Sword local debounce = true local part = script.Parent local function onTouched(part) local player = Players:GetPlayerFromChar(part.Parent.) -- it’s suppose to be GetPlayerFromCharacter if not player then return end if debounce == true then if MarketPlaceService:UserOwnerOfGamePass(UserId id) then -- There are like 4 errors in this, you need assistance with questions local backpack = player.Backpack debounce = false Sword:Clone(1).Parent = backpack wait (1) debounce = true end end end part.Touched:Connect(onTouched) == true -- Don’t add == true

New script:


local id = 7746555 local MarketPlaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local Sword = game.ServerStorage.Sword local debounce = true local part = script.Parent local function onTouched(part) local player = Players:GetPlayerFromCharacter(part.Parent.) if not player then return end if debounce == true then if MarketPlaceService:UserOwnsGamePassAsync(player,UserId id) then local backpack = player.Backpack debounce = false Sword:Clone(1).Parent = backpack wait (1) debounce = true end end end part.Touched:Connect(onTouched)

You have numerous errors, I recommend researching this topic.

0
Doesn’t work ProbablyRiley 0 — 4y
0
Nevermind ProbablyRiley 0 — 4y
Ad

Answer this question