Trouble with a Notification System

Local Script

game.ReplicatedStorage.AlertEvent.OnClientEvent:Connect(function(status)
	local function send(msg, color)
		local frame = game.ReplicatedStorage.msg:Clone()
		frame.TextButton.Text = msg
		frame.Parent = script.Parent.ALERTS
		frame.Visible = true
		if color == "Green" then
		frame.TextButton.TextColor3 = Color3.fromRGB(0, 255, 38)
		elseif color == "Default" then
		frame.TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
		elseif color == "Warning" then
		frame.TextButton.TextColor3 = Color3.fromRGB(255, 0, 0)
		end
	    wait(5)
        frame:Destroy()
	end
	if status == "Payment Success" then
		send("Payment Succesful!","Green")
	elseif status == "Money added" then
		send("FireBux has been added into your account", "Green")
	elseif status == "Free points" then
		send("Some free Fire Points has been added into your account as a thank you by DrxpLoxs, enjoy the free 1,500 FirePoints maybe got a promotion from it :o", "Green")
	elseif status == "No Free points" then
		send(":( Thats sad you are not in our group in order to get free Staff Points for this purchase.", "Warning")
	elseif status == "Payment Failed" then
		send("Payment failed, Unkown error", "Warning")
	elseif status == "Payment Failed Tool" then
		send("Payment failed, Sadly you do not have enough FireBux for this item :(", "Warning")
	elseif status == "Group" then
		send("Remember to check out our group store and join it!", "Default")
	elseif status == "Donation" then
		send("Thank you for the donation, FireBurger thanks you", "Default")
	elseif status == "Adding tool" then
		send("Succesfully chraged your FireBux, Adding tool to your inventory", "Default")
	elseif status == "Spawn Success" then
		send("Succesfully spawned your boat!", "Green")
	elseif status == "Spawn Teleport" then
		send("Teleporting you to your boat in a few seconds!", "Default")
	elseif status == "Exploiter" then
		send("Exploited detected inside of the server, please alert a High Rank", "Warning")
	end
end)

Server Script

game.ReplicatedStorage.BoatEvent.OnServerEvent:Connect(function(player, status, boat)
	local boats = game.ReplicatedStorage.Vehicles
	local spawned = game.Workspace.BoatsSpawned
	local function removeboat()
		if spawned:FindFirstChild(player.Name.."'s Boat") then
			spawned:FindFirstChild(player.Name.."'s Boat"):Destroy()
		end
	end
	local function spawnboat(name)
		local newspawn = boats:FindFirstChild(name):Clone()
		newspawn.Parent = spawned
		newspawn.Name = player.Name.."'s Boat"
		if name == "Speed Boat" then
		player.Character:MoveTo(newspawn.BoatControl.DriverSeat.Position)
		elseif name == "Yacht" then
		player.Character:MoveTo(newspawn.VehicleSeat.Position)
		elseif not name == "Yacht" and not name == "Speed Boat" then
			warn("Error Spawning a boat with the name "..name.." due to it has no special position for driverseat to be teleport to :/")
		end
	end
	if game.MarketplaceService:UserOwnsGamePassAsync(player.UserId, 9104056) or player.Name == "DrxpLoxs" then
	if status == "spawn" then
		if boat == "Speed Boat" then
			removeboat()
			wait(3)
			spawnboat("Speed Boat")
			game.ReplicatedStorage.RemoteEvent:FireClient(player, "Spawn Success")
			game.ReplicatedStorage.RemoteEvent:FireClient(player, "Spawn Teleport")
		elseif boat == "Yacht" then
			removeboat()
			wait(3)
			spawnboat("Yacht")
			game.ReplicatedStorage.RemoteEvent:FireClient(player, "Spawn Success")
			game.ReplicatedStorage.RemoteEvent:FireClient(player, "Spawn Teleport")
		end
	end
	else
		game.ReplicatedStorage.RemoteEvent:FireAllClients("Exploiter")
	    player:Kick("Nice exploiting buddy, get caught by the lord himself, Lord DrxpLoxs")
	end
end)

I don’t know why but its not working.

I’m still looking for support, its been 2 hours.

Shouldn’t RemoteEvent be AlertEvent?

1 Like

FYI: Instead of trailing if statements, you can use a Dictionary to define status messages and colors in a nested Dictionary. For example:

local Statuses = {
    ["Payment Success"] = {Message = "Payment Successful!", Color = "Green"};
};

--// Later on when you receive the status
local Data = Statuses[status];
send(Data.Message, Data.Color);
1 Like