#giving gear on proximity prompt not working
1 messages · Page 1 of 1 (latest)
** You are now Level 4! **
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
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)
No
sorry i dont understand
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)
-- 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)
wow
do ```
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
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
no space
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
lua
lua
its okay
i just needa know why i can only do one or the other
and not both
u want an example or
basically i'm trying to make this script make a prompt so that the player can get a gear
the gear is in the right place and all
it works
ok cool
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
try printing some more I guess
like what