In my game there is a proximity prompt thats supposed to give the player a flashlight tool when they progress through a trapdoor to another level. But the wierd thing about this that i cant seem to fix is that under certian circumstances is just wont work
-
What its like when I spawn directly in the next level
2022-02-02 19-06-59.mp4 - Google Drive -
What its like when played as intended
2022-02-02 19-08-56.mp4 - Google Drive
Script for giving flashlight
local Tools = {"Flashlight"}
local Storage = game:GetService("ServerStorage")
local Part = script.Parent
local prompt = Part:WaitForChild("pickup")
prompt.Triggered:Connect(function(Player)
print("checking for player")
if Player and Player.Character then
print("player found")
local Backpack = Player:WaitForChild("Backpack")
print("checking for tool")
if not Backpack:FindFirstChild("Flashlight") or Player.Character:FindFirstChild("Flashlight") then
print("tool not found in inventory")
for i = 1, #Tools do
local Tool = Storage:FindFirstChild(Tools[i])
if Tool then
print("giving tool")
Tool:clone().Parent = Backpack
end
end
end
end
end)
Any help is appreciated, thanks!