#Proximity Interact Event

1 messages · Page 1 of 1 (latest)

coarse timber
#

I am trying to have a prompt for when its triggered, gives me 10 currency and deletes the npc, but idk how to delete the npc, this is what i have as of now:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InteractEvent = ReplicatedStorage:WaitForChild("InteractEvent")
local Players = game:GetService("Players")

InteractEvent.OnClientEvent:Connect(function(player, npc)
    if not npc or not npc:IsDescendantOf(workspace) then return end
    local humanoid = npc:FindFirstChild("Humanoid")
    if not humanoid then return end

    npc:Destroy()
    
    local stats = player:FindFirstChild("leaderstats")
    if stats then
        local currency = stats:FindFirstChild("¥ZY")
        if currency then
            currency.Value += 10
        end
    end
end)

and this is the script in the proximityprompt

local prompt = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("InteractEvent")

prompt.Triggered:Connect(function(player)
    event:FireClient(player, prompt.Parent)
end)```
the proximity prompt is in the npc model
coarse timber
#

ping me on reply

sly kernelBOT
#

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

blissful zenith
#

its not getting deleted?

blissful zenith
#

the prompt event should be on the server, i dont see any need for the client event

coarse timber
coarse timber
#

Ok, after i moved it for it being on the server, nothing happens

#

it doesnt fire by looks of it

#

i added a debug message to check and nothing happens

#

the debug message is in the function where im firing the event

#

any idea on why this would happen? ive been sitting here for like an hour

blissful zenith
sly kernelBOT
#

studio** You are now Level 8! **studio

blissful zenith
#

in onclientevent, there is no player parameter

#

on onserverevent the first parameter is the player, yes

coarse timber
#

i switched it to onserverevent

#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InteractEvent = ReplicatedStorage:WaitForChild("InteractEvent")

InteractEvent.OnServerEvent:Connect(function(player, npc)
    print(npc)
    if not npc or not npc:IsDescendantOf(workspace) then return end
    print("e")
    local humanoid = npc:FindFirstChild("Humanoid")
    if not humanoid then return end
    print("e")

    npc:Destroy()

    local stats = player:FindFirstChild("leaderstats")
    if stats then
        local currency = stats:FindFirstChild("¥ZY")
        if currency then
            currency.Value += 10
        end
    end
end)
#

current code

blissful zenith
#

what is the issue now

coarse timber
#

the debug messages arent being sent, and in this second part, its not printing its debug message either

local prompt = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("InteractEvent")

prompt.Triggered:Connect(function(player, npc)
    print("Fired")
    event:FireServer(player, prompt.Parent)
end)```
#

put it in a localScript

blissful zenith
#

noel

coarse timber
#

what dumb thing i do now

blissful zenith
#

friend

#

you dont put a player parameter in fireserver

coarse timber
#

oh

blissful zenith
#

the player parameter is there automatically

#

this:

event:FireServer(player, prompt.Parent)

would be just this:

event:FireServer(prompt.Parent)

coarse timber
#

didnt know

blissful zenith
#

on onclientevent you dont put a player parameter either

coarse timber
#

i should read the docs more carefuly..

#

alr, removed that but still nothing being printed to console

#

might leave ts for tmr, i am generally too tired for this

amber rune
#

while true do

coarse timber