Hello! I am trying to make a survival game where you can pick up objects. With Proximity Prompts but for some reason if you pick up one object it executes the code of every object. Does anyone know why?
This code is written in a serverscript And their directories are Workspace.Stone.ProximityPrompt.Script Workspace.Log.ProximityPrompt.Script
Stone Object Code
local proximitypromptservice = game:GetService("ProximityPromptService") local proximityprompt = script.Parent local stone = game.ServerStorage.Items.Stone local part = script.Parent.Parent proximitypromptservice.PromptTriggered:Connect(function(promptObject, player) local inventoryslots = player.InventoryUsed local playergui = player:WaitForChild("PlayerGui") if inventoryslots.Value >= 6 then playergui.FullInventory.Frame.Visible = true wait(3) playergui.FullInventory.Frame.Visible = false else stone:Clone() stone.Parent = player.Backpack inventoryslots.Value = inventoryslots.Value + 1 part:Destroy() end end)
Log Object Code:
local proximitypromptservice = game:GetService("ProximityPromptService") local proximityprompt = script.Parent local log = game.ServerStorage.Items.Log proximitypromptservice.PromptTriggered:Connect(function(promptObject, player) local inventoryslots = player.InventoryUsed local playergui = player:WaitForChild("PlayerGui") if inventoryslots.Value >= 6 then playergui.FullInventory.Frame.Visible = true wait(3) playergui.FullInventory.Frame.Visible = false else log:Clone() log.Parent = player.Backpack inventoryslots.Value = inventoryslots.Value + 1 script.Parent.Parent:Destroy() end end)
I'm really confused on why this is happening. Can anyone explains why this happens?