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

Why wont the ProximityPromt become active?

Asked by 1 year ago
Edited 1 year ago

im a little new to scripting but why doesn't this fire?

localscript

local proxy = script.Parent.ProximityPrompt
local event = game:GetService("ServerStorage"):WaitForChild("HasCrowbar")

if event.OnClientEvent then
    proxy.Enabled = true
end

event.OnClientEvent:Connect(oneventFired)

here's the other side of the code

script

local promt = script.Parent

local original = game:GetService("ReplicatedStorage"):WaitForChild("Crowbar")
local event = game:GetService("ServerStorage"):WaitForChild("HasCrowbar")

local spots = script.Parent.Parent.Parent

promt.TriggerEnded:Connect(function(player)
    local new = original:Clone()
    new.Parent = player.Backpack
    print("player has crowbar")
    event:FireClient(player)
    wait(0.2)
    spots:Destroy()
end)

3 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
1 year ago
Edited 1 year ago

I cooked up a new script for you!

The problem is you can't check if the event has been fired, you have no function so the OnClientEvent will not fire which will bring you an error of no function found

If the script works, I'd appreciate it a lot if you accept my answer!

Here's your script, It must be a Local Script

local proxy = script.Parent.ProximityPrompt
local hasCrowbarRE = game:GetService("ServerStorage"):WaitForChild("HasCrowbar")

hasCrowbarRE.OnClientEvent:Connect(function()
    proxy.Enabled = true
end)
0
the code did not work unfortunately, I've edited my post to show the other side dispenseer 0 — 1y
0
Are you trying to disable the proximity prompt? MattVSNNL 620 — 1y
0
im trying to enable it dispenseer 0 — 1y
Ad
Log in to vote
0
Answered by
bdam3000 125
1 year ago
Edited 1 year ago

You can't access ServerStorage on the client. It can only be used by server scripts. Try placing the event in ReplicatedStorage

local proxy = script.Parent.ProximityPrompt
local event = game:GetService("ReplicatedStorage"):WaitForChild("HasCrowbar") -- Change if you want

event.OnClientEvent:Connect(function()
    proxy.Enabled = true
end)


You would also change the location reference in the Server script

local promt = script.Parent

local original = game:GetService("ReplicatedStorage"):WaitForChild("Crowbar")
local event = game:GetService("ReplicatedStorage"):WaitForChild("HasCrowbar") -- Change if you want

local spots = script.Parent.Parent.Parent

promt.TriggerEnded:Connect(function(player)
    local new = original:Clone()
    new.Parent = player.Backpack
    print("player has crowbar")
    event:FireClient(player)
    wait(0.2)
    spots:Destroy()
end)
0
sadly didn't work, do you think perhaps reworking the local script to a server side one would be better? dispenseer 0 — 1y
Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question