Client Base Error

I want do disable just a proximityprompt for one client but it doesn’t work.
( And UI’s doesn’t being visible at LocalScript)

image

Script:

script.Parent.Triggered:Connect(function(player)
	if player.config.job.Value == game.ReplicatedStorage.jobs.weapon_dealer.Value then
		print("weapon_dealer EVENT_A1")		
		script.Parent.RemoteEvent2:FireClient(player)
	else
		script.Parent.RemoteEvent:FireClient(player)
	end
end)

LocalScript:

script.Parent.RemoteEvent.OnClientEvent:Connect(function(player)
		player.PlayerGui.alert.Frame.weapondealeralert_a.Visible = true
		script.Parent.Enabled = false
		wait(7)
		player.PlayerGui.alert.Frame.weapondealeralert_a.Visible = false
		script.Parent.Enabled = true
end)

LocalScript2:

script.Parent.RemoteEvent2.OnClientEvent:Connect(function(player)
	script.Parent.Parent.sound:Play()
end)
2 Likes

What exactly doesn’t work? Any errors?
Try returning after firing the RemoteEvent2 and the RemoteEvent.

1 Like

You also really don’t need 2 separate scripts/remotes for this.

2 Likes

it doesnt print any error but its doesnt happening

1 Like

You’re disabling the script and then expecting it to suddenly re-enable itself after a couple seconds. You could have a debounce on the server for the player and if they are still on cooldown then don’t fire client. No need to disable/enable the script. Just toggle visibility. Let the server or client do the cooldowns to prevent firing

1 Like

Can you explain it in simpler terms? I’m new at studio, sorry.
(and I’m sure i’m disabling the proximityprompt)

Alright. Use one remote event. One local script.

Server Code:

script.Parent.Triggered:Connect(function(player)
	if player.config.job.Value == game.ReplicatedStorage.jobs.weapon_dealer.Value then
		print("weapon_dealer EVENT_A1")
		script.Parent.RemoteEvent:FireClient(player, "doAnotherThing")
	else
		script.Parent.RemoteEvent:FireClient(player, "doThing")
	end
end)

Client Code:

local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

script.Parent.RemoteEvent.OnClientEvent:Connect(function(action)
	if action == "doThing" then
		playerGui.alert.Frame.weapondealeralert_a.Visible = true
		task.wait(7)
		playerGui.alert.Frame.weapondealeralert_a.Visible = false
	else if action == "doAnotherThing" then
	   	script.Parent.Parent.sound:Play()
	end
end)

I may have missed something, wrote this pretty quickly. But hopefully you get the idea.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.