Oh that was a typo I think. babbab
It is in a script, and okeh. I’ll try everythingi na bit.
local ServerStorage = game:GetService("ServerStorage")
local LocalHamonKick = ServerStorage:WaitForChild("LocalHamonKick")
function GiveKick(player)
local Backpack = player:WaitForChild("Backpack")
local MarketplaceService = game:GetService("MarketplaceService")
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, 23171784) then
LocalHamonKick:Clone().Parent = Backpack
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
GiveKick(player)
end)
end)
I’m on mobile right now, so it’s hard to type and I can’t access RS.
I would also use this
local success,err = pcall(function()
MarketplaceService:UserOwnsGamePassAsync(player.UserId,gamepassId) -- or try adding a return at the beginning of this if it wont work
end)
if success then
--code here
else
warn("Player Doesn't own Gamepass")
end
A failure on success, doesn’t mean they don’t own it, just there was a problem checking with the Roblox servers.
I know I just use Player Doesn't own Gamepass
it is how I do prints doesn’t change the fact it works
function GiveKick(player)
local Backpack = player:WaitForChild("Backpack")
local MarketplaceService = game:GetService("MarketplaceService")
local success,result = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, 23171784)
end)
if success then
if result == true then
LocalHamonKick:Clone().Parent = Backpack
else
--doesnt own
end
else
print(result) --result holds the error code
end
end
Give me a second to test this all, since the person with the gamepass isn’t online right now, So I might respond a bit later.
you can always test without the gamepass owner, by replacing the gamepass id number with a gamepass id that you currently own.
Btw as I learned result is an false value so it is like the error I learned this from using DataStores by TheDevKing
Oh okeh.That makes sense.
Well, think of it like this…
if the pcall is ‘success == true’ then result will be whatever you ‘return’ from inside the pcall
if the pcall is ‘success == false’ then result will hold the error message
bro. u have to first wait for the script to load in the player’s backpack.
then check if it exists , then run the code.
local hamonKickGui = plr:WaitForChild("Backpack"):WaitForChild("HamonKick")
if hamonKickGui then
-- code here
else
return
end
I’ve got a problem, I’m attempting to get the character from the hit, but it’s not working.
The problem is on line 27.
game.ReplicatedStorage.HamonKick.OnServerEvent:Connect(function(Player)
local char = Player.Character or Player.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
local Kick = hum:LoadAnimation(script:WaitForChild("Kick"))
Kick:Play()
local HitBox = script:WaitForChild("HitBox"):Clone()
HitBox.CFrame = char:FindFirstChild("Left Leg").CFrame
HitBox.Parent = char:FindFirstChild("Left Leg")
local Pweld = Instance.new("Weld")
Pweld.Part0 = HitBox
Pweld.Part1 = char:FindFirstChild("Left Leg")
Pweld.C0 = HitBox.CFrame:inverse() * char:FindFirstChild("Left Leg").CFrame
Pweld.Parent = Pweld.Part0
HitBox.Touched:Connect(function(Hit)
if Hit:IsA("Part") or Hit:IsA("MeshPart") then
if Hit.Parent ~= char then
local EHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
HitBox:Destroy()
if Hit.Parent:FindFirstChild('Left Leg') then
local enplr = Hit:GetPlayerFromCharacter(Hit.Parent)
local HumanoidRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(50)
local vel = Instance.new("BodyVelocity",workspace.HumanoidRP)
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
vel.Velocity = workspace.char.HumanoidRootPart.CFrame.lookVector * 45
wait(1)
vel:Destroy()
if Hit.Parent.Humanoid.Health < 1 then
enplr:Kick("You got kicked by someone who wasted their money...")
end
end
end
end
end
end)
end)
There are no line numbers, so which is line 27, and is it giving you an error, or not, in other words how do you know the problem is on line 27
Oh, sorry about that. It is erroring, the specific line of code is local enplr = Hit:GetPlayerFromCharacter(Hit.Parent). It’s near the bottom. I know its erroring because of out put. The error says, Unable to get player from character from _. It shows the name of a body part, for example left leg, but is still failing to get the player from it. I don’t have an image, because I am once again outside.
try… enplr = game.Players:GetPlayerFromCharacter(Hit.Parent)
Well, it’s not erroring anymore, but It won’t kick either.
Here is the important piece of code:
if Humanoid then
HitBox:Destroy()
if Hit.Parent:FindFirstChild('Right Arm') then
local enplr = game.Players:GetPlayerFromCharacter(Hit.Parent)
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(50)
local vel = Instance.new("BodyVelocity",EHumRP)
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
vel.Velocity = HumRP.CFrame.lookVector * 70
wait(1)
vel:Destroy()
if Humanoid.Health < 1 then
enplr:Kick("Someone wasted their money apparently...")
Player.leaderstats.moneys.Value = Player.leaderstats.moneys.Value + 50
end
end
not sure why you are trying to find Right Arm… but where does the code get to, does it ever get to the part of :TakeDamage(50) ? Or not?
also by ‘it wont kick’ do you mean just the pushing of the other character?