Hello, i want the script to enable a UI when a proximityprompt has been triggered, ive tried it with remoteevents but it wont work, im new to remotevents so dont be to suprised here is my script that should fire the remotevent:
local proxpromt = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperevent = repstorage.PaperEvent
proxpromt.Triggered:Connect(function()
paperevent:FireClient()
end)
here is my event (its the paperevent):
here is my local script thats inside startercharacterscripts:
local PaperEvent = game.ReplicatedStorage.PaperEvent
local player = game.Players.LocalPlayer
PaperEvent.OnClientEvent:Connect(function()
if player.PlayerGui.ScreenGui.Enabled == false then
player.PlayerGui.ScreenGui.Enabled = true
else
return nil
end
end)
here is the error i get from the output that says something is wrong with the normal script, not the local one.
Sometimes RemoteEvents don’t work. I tried using a remote event once and about a quarter of the time it would just run one line of code and stop.
Try:
local proxpromt = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperevent = repstorage.PaperEvent
proxpromt.Triggered:Connect(function()
player.PlayerGui.ScreenGui.Enabled = not player.PlayerGui.ScreenGui.Enabled
end)
Hopefully this fixes your issue.
Edit: On the fire client argument, you need to reference the player inside the brackets.
i got a question, the code you sent worked, now im working on a button that would close it.
it says player argument must be a player object.
local button = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
local paperendevent = repstorage:WaitForChild("PaperEndEvent")
button.MouseButton1Click:Connect(function(player)
paperendevent:FireClient(player)
end)