#giving gear on proximity prompt not working

1 messages · Page 1 of 1 (latest)

celest glacier
#

heyo, i want to know why my scripts can't work together lol. I have gears that require 5,10,15 wins and so on, and I also have a gear that is a secret you have to find. both of these have proximity prompts, but when I get a gear from one, I can't get one from the other. Can someone help? thanks.

pine waveBOT
#

studio** You are now Level 4! **studio

celest glacier
#

local part = script.Parent
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

if not coraTool then
warn("cora tool not found in ReplicatedStorage!")
return
end

proximityPrompt.Triggered:Connect(function(player)
print(player.Name .. " triggered the prompt")
if player and player:FindFirstChild("Backpack") then
local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

    if not hasInBackpack and not hasEquipped then
        print("Giving tool to", player.Name)
        local newTool = coraTool:Clone()
        newTool.Parent = player.Backpack
    else
        print(player.Name .. " already has " .. coraTool.Name)
    end
else
    warn("Player backpack not found!")
end

end)
this is the script for the "secret" gear

#

and the others r basically the same but require wins

final epoch
#

Can you format the lua script?

celest glacier
# final epoch Can you format the lua script?

-- gets the part this script is attached to
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
warn("cora tool not found in ReplicatedStorage!")
return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
print(player.Name .. " triggered the prompt")

if player and player:FindFirstChild("Backpack") then
    -- checks if the player alr has the tool so he cant get it twice
    local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
    local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

    if not hasInBackpack and not hasEquipped then
        print("Giving tool to", player.Name)
        local newTool = coraTool:Clone()
        newTool.Parent = player.Backpack
    else
        print(player.Name .. " already has " .. coraTool.Name)
    end
else
    warn("Player backpack not found!")
end

end)

final epoch
#

No

celest glacier
#

sorry i dont understand

final epoch
#

like this

-- gets the part this script is attached to
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
    warn("cora tool not found in ReplicatedStorage!")
    return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
    print(player.Name .. " triggered the prompt")

    if player and player:FindFirstChild("Backpack") then
        -- checks if the player alr has the tool so he cant get it twice
        local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
        local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

        if not hasInBackpack and not hasEquipped then
            print("Giving tool to", player.Name)
            local newTool = coraTool:Clone()
            newTool.Parent = player.Backpack
        else
            print(player.Name .. " already has " .. coraTool.Name)
        end
    else
        warn("Player backpack not found!")
    end
end)
celest glacier
#

oh

#

how do i do that

final epoch
#
-- gets the part this script is attached to
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
    warn("cora tool not found in ReplicatedStorage!")
    return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
    print(player.Name .. " triggered the prompt")

    if player and player:FindFirstChild("Backpack") then
        -- checks if the player alr has the tool so he cant get it twice
        local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
        local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

        if not hasInBackpack and not hasEquipped then
            print("Giving tool to", player.Name)
            local newTool = coraTool:Clone()
            newTool.Parent = player.Backpack
        else
            print(player.Name .. " already has " .. coraTool.Name)
        end
    else
        warn("Player backpack not found!")
    end
end)
celest glacier
#

wow

final epoch
#

do ```

celest glacier
#

i never knew sorry

#

whats that 💀

final epoch
#

do three `

#

in a row

celest glacier
#

oh ok

#
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
    warn("cora tool not found in ReplicatedStorage!")
    return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
    print(player.Name .. " triggered the prompt")

    if player and player:FindFirstChild("Backpack") then
        -- checks if the player alr has the tool so he cant get it twice
        local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
        local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

        if not hasInBackpack and not hasEquipped then
            print("Giving tool to", player.Name)
            local newTool = coraTool:Clone()
            newTool.Parent = player.Backpack
        else
            print(player.Name .. " already has " .. coraTool.Name)
        end
    else
        warn("Player backpack not found!")
    end
end)
#

how do i make it color coded

final epoch
#

do lua

#

after the three `

#

in the first one

celest glacier
#

k bet wait

#
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
    warn("cora tool not found in ReplicatedStorage!")
    return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
    print(player.Name .. " triggered the prompt")

    if player and player:FindFirstChild("Backpack") then
        -- checks if the player alr has the tool so he cant get it twice
        local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
        local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

        if not hasInBackpack and not hasEquipped then
            print("Giving tool to", player.Name)
            local newTool = coraTool:Clone()
            newTool.Parent = player.Backpack
        else
            print(player.Name .. " already has " .. coraTool.Name)
        end
    else
        warn("Player backpack not found!")
    end
end)
#

after the three ` right

final epoch
#

no space

celest glacier
#
local part = script.Parent

-- creates a proximity prompt
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.ActionText = "??"
proximityPrompt.ObjectText = "???"
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.E
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.HoldDuration = 5
proximityPrompt.MaxActivationDistance = 10
proximityPrompt.Parent = part

-- finds the gear in replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coraTool = ReplicatedStorage:FindFirstChild("cora")

-- check if the tool exists (just testing)
if not coraTool then
    warn("cora tool not found in ReplicatedStorage!")
    return
end

-- more testing
proximityPrompt.Triggered:Connect(function(player)
    print(player.Name .. " triggered the prompt")

    if player and player:FindFirstChild("Backpack") then
        -- checks if the player alr has the tool so he cant get it twice
        local hasInBackpack = player.Backpack:FindFirstChild(coraTool.Name)
        local hasEquipped = player.Character and player.Character:FindFirstChild(coraTool.Name)

        if not hasInBackpack and not hasEquipped then
            print("Giving tool to", player.Name)
            local newTool = coraTool:Clone()
            newTool.Parent = player.Backpack
        else
            print(player.Name .. " already has " .. coraTool.Name)
        end
    else
        warn("Player backpack not found!")
    end
end)```
#

there is no space

final epoch
celest glacier
#

lua

final epoch
#

hrm

#

idk

celest glacier
#

lua

#

its okay

#

i just needa know why i can only do one or the other

#

and not both

#

u want an example or

final epoch
#

anyways

#

why your script is not working

#

idk

#

what are you trying to do?

celest glacier
#

the gear is in the right place and all

#

it works

final epoch
#

ok cool

celest glacier
#

but if I try to get any other glove it doesnt work anymore

#

i cant get the others again

#

even if i respawn

#

its one or the other, and its the same thing vice versa

#

its hard to explain

final epoch
#

try printing some more I guess

celest glacier
#

like what

final epoch
#

do print(player:GetChildren())

#

when testing to see if things exist to it

#

it will bring up stuff like this in the output

#

good lock

#

luck

celest glacier
#

ima be honest i suck at lua so much 😭

#

idk what im doing lmao