Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my proximity prompt only work sometimes?

Asked by 2 years ago
Edited 2 years ago

I am currently creating a system which allows a player to pick up a tool using a proximity prompt and drop it using the letter "X" on their keyboard. My only issue is that sometimes the proximity prompt does nothing upon activation.

https://ibb.co/58XfrKr is the explorer view of the item

below are the scripts which I think could be causing problems

this is the ProximityPromptHandler

local ProximityPrompt = script.Parent.Handle.ProximityPrompt
ProximityPrompt.Triggered:connect(function(Player)
    script.Parent.Parent = Player.Backpack
end)

this is the DropHandler

local UserInputService = game:GetService("UserInputService")
local tool = script.Parent
local character = game:GetService('Players').LocalPlayer.Character
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local function IsKeyDown()
    return UserInputService:IsKeyDown(Enum.KeyCode.X)
end

local function Input(input, gameProcessedEvent)
    if IsKeyDown() then
        if tool.Parent == character then
        tool.Parent = game.Workspace
        tool.Handle.Anchored = true
        tool.Handle.CanCollide = false
        tool.Handle.Transparency = 1
        wait(0.1)
        tool.Handle.CanCollide = false
        tool.Handle.CFrame = CFrame.new(character.HumanoidRootPart.Position.X, script.Parent.Ground.Value + 0.5, character.HumanoidRootPart.Position.Z)
        tool.Handle.Transparency = 0
        tool.Handle.ProximityPrompt.Enabled = true
        tool.Handle.CanCollide = false
    end
    end
    end

UserInputService.InputBegan:Connect(Input)
0
maybe your keyboard has some problems as i dont see any problem with the ProximityPromptHandler? Puppynniko 1059 — 2y

Answer this question